Enable function GetProcessMemoryInfo() to get reliable memory usage data

for MINGW and MSVC console, WinGui and MSVC shared ngspice.
MINGW shared ngspice does not link to psapi.dll, so cannot
apply  GetProcessMemoryInfo(),  but sticks to unreliable function
GlobalMemoryStatusEx().
This commit is contained in:
Holger Vogt 2018-11-10 16:36:15 +01:00
parent 035156be66
commit cf6722af17
2 changed files with 11 additions and 1 deletions

View File

@ -334,6 +334,15 @@ if WINGUI
LIBS += -lpsapi
endif
if WINCONSOLE
LIBS += -lpsapi
endif
## FIXME: Should be allwed, but fails within MSYS2
#if SHWIN
#LIBS += -lpsapi
#endif
CLEANFILES = ngspice.idx spinit tclspinit pkgIndex.tcl
MAINTAINERCLEANFILES = Makefile.in

View File

@ -479,7 +479,8 @@ fprintmem(FILE *stream, unsigned long long memory) {
static int get_procm(struct proc_mem *memall) {
#if defined(_MSC_VER) || defined(__MINGW32__)
#if (_WIN32_WINNT >= 0x0500) && defined(HAS_WINGUI)
/* FIXME: shared module should be allowed, but currently does not link to psapi within MINGW/MSYS2 */
#if (_WIN32_WINNT >= 0x0500) && (!defined(SHARED_MODULE) || _MSC_VER)
/* Use Windows API function to obtain size of memory - more accurate */
HANDLE hProcess;
PROCESS_MEMORY_COUNTERS pmc;