Bug 913953 - Part j: Remove unused GetWorkingSetKBytes function; r=ehsan

This commit is contained in:
Ms2ger 2013-09-10 09:03:34 +02:00
parent c12bc71999
commit 9d4280b585
2 changed files with 0 additions and 84 deletions

View File

@ -267,18 +267,6 @@ class NamedProcessIterator {
DISALLOW_EVIL_CONSTRUCTORS(NamedProcessIterator);
};
// Working Set (resident) memory usage broken down by
// priv (private): These pages (kbytes) cannot be shared with any other process.
// shareable: These pages (kbytes) can be shared with other processes under
// the right circumstances.
// shared : These pages (kbytes) are currently shared with at least one
// other process.
struct WorkingSetKBytes {
size_t priv;
size_t shareable;
size_t shared;
};
// Committed (resident + paged) memory usage broken down by
// private: These pages cannot be shared with any other process.
// mapped: These pages are mapped into the view of a section (backed by
@ -328,9 +316,6 @@ class ProcessMetrics {
// Fills a CommittedKBytes with both resident and paged
// memory usage as per definition of CommittedBytes.
void GetCommittedKBytes(CommittedKBytes* usage) const;
// Fills a WorkingSetKBytes containing resident private and shared memory
// usage in bytes, as per definition of WorkingSetBytes.
bool GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const;
// Returns the CPU usage in percent since the last time this method was
// called. The first time this method is called it returns 0 and will return

View File

@ -544,75 +544,6 @@ void ProcessMetrics::GetCommittedKBytes(CommittedKBytes* usage) const {
usage->priv = committed_private / 1024;
}
bool ProcessMetrics::GetWorkingSetKBytes(WorkingSetKBytes* ws_usage) const {
size_t ws_private = 0;
size_t ws_shareable = 0;
size_t ws_shared = 0;
DCHECK(ws_usage);
memset(ws_usage, 0, sizeof(*ws_usage));
DWORD number_of_entries = 4096; // Just a guess.
PSAPI_WORKING_SET_INFORMATION* buffer = NULL;
int retries = 5;
for (;;) {
DWORD buffer_size = sizeof(PSAPI_WORKING_SET_INFORMATION) +
(number_of_entries * sizeof(PSAPI_WORKING_SET_BLOCK));
// if we can't expand the buffer, don't leak the previous
// contents or pass a NULL pointer to QueryWorkingSet
PSAPI_WORKING_SET_INFORMATION* new_buffer =
reinterpret_cast<PSAPI_WORKING_SET_INFORMATION*>(
realloc(buffer, buffer_size));
if (!new_buffer) {
free(buffer);
return false;
}
buffer = new_buffer;
// Call the function once to get number of items
if (QueryWorkingSet(process_, buffer, buffer_size))
break; // Success
if (GetLastError() != ERROR_BAD_LENGTH) {
free(buffer);
return false;
}
number_of_entries = static_cast<DWORD>(buffer->NumberOfEntries);
// Maybe some entries are being added right now. Increase the buffer to
// take that into account.
number_of_entries = static_cast<DWORD>(number_of_entries * 1.25);
if (--retries == 0) {
free(buffer); // If we're looping, eventually fail.
return false;
}
}
// On windows 2000 the function returns 1 even when the buffer is too small.
// The number of entries that we are going to parse is the minimum between the
// size we allocated and the real number of entries.
number_of_entries =
std::min(number_of_entries, static_cast<DWORD>(buffer->NumberOfEntries));
for (unsigned int i = 0; i < number_of_entries; i++) {
if (buffer->WorkingSetInfo[i].Shared) {
ws_shareable++;
if (buffer->WorkingSetInfo[i].ShareCount > 1)
ws_shared++;
} else {
ws_private++;
}
}
ws_usage->priv = ws_private * PAGESIZE_KB;
ws_usage->shareable = ws_shareable * PAGESIZE_KB;
ws_usage->shared = ws_shared * PAGESIZE_KB;
free(buffer);
return true;
}
static uint64_t FileTimeToUTC(const FILETIME& ftime) {
LARGE_INTEGER li;
li.LowPart = ftime.dwLowDateTime;