Home || Visual Search || Applications || Architecture || Important Messages || OGL || Src

static Int64 Impala::Process::MemoryInfo::GetUsage (  )  [inline, static]

Definition at line 37 of file MemoryInfo.h.

Referenced by GetUsageSinceMark(), GetUsageSinceMarkString(), GetUsageString(), MarkFrom(), MarkTo(), and PrintUsage().

00038     {
00039         Int64 usage = -1;
00040 #ifdef WIN32
00041         PROCESS_MEMORY_COUNTERS info;
00042         bool result = GetProcessMemoryInfo(GetCurrentProcess(), &info,
00043                                            sizeof(info));
00044         if (result)
00045         {
00046             usage = info.WorkingSetSize + info.QuotaPagedPoolUsage +
00047                 info.QuotaNonPagedPoolUsage + info.PagefileUsage;
00048         }
00049         else
00050         {
00051             usage = -2;
00052         }
00053 #else
00054         long pageSize = sysconf(_SC_PAGE_SIZE);
00055         char buf[100];
00056         sprintf(buf, "/proc/%u/statm", (unsigned) getpid());
00057         FILE* fp = fopen(buf, "r");
00058         if (fp)
00059         {
00060             unsigned size;
00061             fscanf(fp, "%u", &size);
00062             usage = (Int64) size * (Int64) pageSize;
00063             fclose(fp);
00064         }
00065         else
00066         {
00067             usage = -2;
00068         }
00069 #endif
00070         return usage;
00071     }


Generated on Thu Jan 13 09:24:00 2011 for ImpalaSrc by  doxygen 1.5.1