From: stevenknight Date: Sun, 12 Feb 2006 13:03:27 +0000 (+0000) Subject: Support the --debug=memory option on Windows. (Baptiste Lepilleur) X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8ff1faecc86ee03dd2d7706217854c65e171c7bf;p=scons.git Support the --debug=memory option on Windows. (Baptiste Lepilleur) git-svn-id: http://scons.tigris.org/svn/scons/trunk@1418 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 754768df..1407e3ff 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -126,6 +126,11 @@ RELEASE 0.97 - XXX - Add x64 support for Microsoft Visual Studio 8. + From Baptiste Lepilleur: + + - Support the --debug=memory option on Windows when the Python version + has the win32process and win32api modules. + From Christian Maaser: - Add support for Visual Studio Express Editions. diff --git a/src/engine/SCons/Debug.py b/src/engine/SCons/Debug.py index bb49dbd3..cc97fe02 100644 --- a/src/engine/SCons/Debug.py +++ b/src/engine/SCons/Debug.py @@ -98,8 +98,17 @@ else: try: import resource except ImportError: - def memory(): - return 0 + try: + import win32process + import win32api + except ImportError: + def memory(): + return 0 + else: + def memory(): + process_handle = win32api.GetCurrentProcess() + memory_info = win32process.GetProcessMemoryInfo( process_handle ) + return memory_info['PeakWorkingSetSize'] else: def memory(): res = resource.getrusage(resource.RUSAGE_SELF) diff --git a/test/option/debug-memory.py b/test/option/debug-memory.py index 0a2875f4..9ed674e2 100644 --- a/test/option/debug-memory.py +++ b/test/option/debug-memory.py @@ -39,8 +39,12 @@ test = TestSCons.TestSCons() try: import resource except ImportError: - x = "Python version has no 'resource' module; skipping tests.\n" - test.skip_test(x) + try: + import win32process + import win32api + except ImportError: + x = "Python version has no 'resource' or 'win32api/win32process' module; skipping tests.\n" + test.skip_test(x)