Merge branch 'sigar-1.6'
This commit is contained in:
commit
37c22746b2
|
@ -48,9 +48,9 @@ public class TestMem extends SigarTestCase {
|
|||
|
||||
assertGtZeroTrace("Free", mem.getFree());
|
||||
|
||||
assertGtZeroTrace("ActualUsed", mem.getUsed());
|
||||
assertGtZeroTrace("ActualUsed", mem.getActualUsed());
|
||||
|
||||
assertGtZeroTrace("ActualFree", mem.getFree());
|
||||
assertGtZeroTrace("ActualFree", mem.getActualFree());
|
||||
|
||||
assertGtZeroTrace("Ram", mem.getRam());
|
||||
|
||||
|
|
|
@ -170,28 +170,10 @@ typedef enum {
|
|||
SC_STATUS_PROCESS_INFO = 0
|
||||
} SC_STATUS_TYPE;
|
||||
|
||||
typedef struct _PERFORMANCE_INFORMATION {
|
||||
DWORD cb;
|
||||
SIZE_T CommitTotal;
|
||||
SIZE_T CommitLimit;
|
||||
SIZE_T CommitPeak;
|
||||
SIZE_T PhysicalTotal;
|
||||
SIZE_T PhysicalAvailable;
|
||||
SIZE_T SystemCache;
|
||||
SIZE_T KernelTotal;
|
||||
SIZE_T KernelPaged;
|
||||
SIZE_T KernelNonpaged;
|
||||
SIZE_T PageSize;
|
||||
DWORD HandleCount;
|
||||
DWORD ProcessCount;
|
||||
DWORD ThreadCount;
|
||||
} PERFORMANCE_INFORMATION, *PPERFORMANCE_INFORMATION;
|
||||
|
||||
#ifndef ERROR_DATATYPE_MISMATCH
|
||||
#define ERROR_DATATYPE_MISMATCH 1629L
|
||||
#endif
|
||||
#else
|
||||
#include <psapi.h>
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#include <iprtrmib.h>
|
||||
|
@ -459,8 +441,6 @@ typedef BOOL (CALLBACK *psapi_enum_processes)(DWORD *,
|
|||
DWORD,
|
||||
DWORD *);
|
||||
|
||||
typedef BOOL (CALLBACK *psapi_get_perf_info)(PPERFORMANCE_INFORMATION, DWORD);
|
||||
|
||||
/* winsta.dll */
|
||||
typedef BOOLEAN (CALLBACK *winsta_query_info)(HANDLE,
|
||||
ULONG,
|
||||
|
@ -538,7 +518,6 @@ typedef struct {
|
|||
SIGAR_DLLFUNC(psapi, enum_modules);
|
||||
SIGAR_DLLFUNC(psapi, enum_processes);
|
||||
SIGAR_DLLFUNC(psapi, get_module_name);
|
||||
SIGAR_DLLFUNC(psapi, get_perf_info);
|
||||
|
||||
sigar_dll_func_t end;
|
||||
} sigar_psapi_t;
|
||||
|
|
|
@ -235,7 +235,7 @@ static PERF_OBJECT_TYPE *get_perf_object_inst(sigar_t *sigar,
|
|||
#define get_perf_object(sigar, counter_key, err) \
|
||||
get_perf_object_inst(sigar, counter_key, 1, err)
|
||||
|
||||
static int get_swap_counters(sigar_t *sigar, sigar_swap_t *swap)
|
||||
static int get_mem_counters(sigar_t *sigar, sigar_swap_t *swap, sigar_mem_t *mem)
|
||||
{
|
||||
int status;
|
||||
PERF_OBJECT_TYPE *object =
|
||||
|
@ -259,10 +259,17 @@ static int get_swap_counters(sigar_t *sigar, sigar_swap_t *swap)
|
|||
|
||||
switch (counter->CounterNameTitleIndex) {
|
||||
case 48: /* "Pages Output/sec" */
|
||||
swap->page_out = *((DWORD *)(data + offset));
|
||||
if (swap) swap->page_out = *((DWORD *)(data + offset));
|
||||
break;
|
||||
case 76: /* "System Cache Resident Bytes" aka file cache */
|
||||
if (mem) {
|
||||
sigar_uint64_t kern = *((DWORD *)(data + offset));
|
||||
mem->actual_free = mem->free + kern;
|
||||
mem->actual_used = mem->used - kern;
|
||||
return SIGAR_OK;
|
||||
}
|
||||
case 822: /* "Pages Input/sec" */
|
||||
swap->page_in = *((DWORD *)(data + offset));
|
||||
if (swap) swap->page_in = *((DWORD *)(data + offset));
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
|
@ -343,7 +350,6 @@ static sigar_psapi_t sigar_psapi = {
|
|||
{ "EnumProcessModules", NULL },
|
||||
{ "EnumProcesses", NULL },
|
||||
{ "GetModuleFileNameExA", NULL },
|
||||
{ "GetPerformanceInfo", NULL },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
@ -633,14 +639,9 @@ char *sigar_os_error_string(sigar_t *sigar, int err)
|
|||
#define sigar_GlobalMemoryStatusEx \
|
||||
sigar->kernel.memory_status.func
|
||||
|
||||
#define sigar_GetPerformanceInfo \
|
||||
sigar->psapi.get_perf_info.func
|
||||
|
||||
SIGAR_DECLARE(int) sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
|
||||
{
|
||||
sigar_uint64_t kern = 0;
|
||||
DLLMOD_INIT(kernel, TRUE);
|
||||
DLLMOD_INIT(psapi, FALSE);
|
||||
|
||||
if (sigar_GlobalMemoryStatusEx) {
|
||||
MEMORYSTATUSEX memstat;
|
||||
|
@ -653,14 +654,6 @@ SIGAR_DECLARE(int) sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
|
|||
|
||||
mem->total = memstat.ullTotalPhys;
|
||||
mem->free = memstat.ullAvailPhys;
|
||||
|
||||
if (sigar_GetPerformanceInfo) {
|
||||
PERFORMANCE_INFORMATION info;
|
||||
if (sigar_GetPerformanceInfo(&info, sizeof(info))) {
|
||||
kern = info.SystemCache;
|
||||
kern *= sigar->pagesize;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
MEMORYSTATUS memstat;
|
||||
|
@ -671,8 +664,10 @@ SIGAR_DECLARE(int) sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
|
|||
|
||||
mem->used = mem->total - mem->free;
|
||||
|
||||
mem->actual_free = mem->free + kern;
|
||||
mem->actual_used = mem->used - kern;
|
||||
mem->actual_free = mem->free;
|
||||
mem->actual_used = mem->used;
|
||||
/* set actual_{free,used} */
|
||||
get_mem_counters(sigar, NULL, mem);
|
||||
|
||||
sigar_mem_calc_ram(sigar, mem);
|
||||
|
||||
|
@ -705,7 +700,7 @@ SIGAR_DECLARE(int) sigar_swap_get(sigar_t *sigar, sigar_swap_t *swap)
|
|||
|
||||
swap->used = swap->total - swap->free;
|
||||
|
||||
if (get_swap_counters(sigar, swap) != SIGAR_OK) {
|
||||
if (get_mem_counters(sigar, swap, NULL) != SIGAR_OK) {
|
||||
swap->page_in = SIGAR_FIELD_NOTIMPL;
|
||||
swap->page_out = SIGAR_FIELD_NOTIMPL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue