From 5783a52a9c6dc12f6d60f69cb095efec84468373 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 18 Oct 2011 14:30:31 -0700 Subject: [PATCH] Remove process.memoryUsage().vsize Not meaningful cross platform; unused. --- doc/api/process.markdown | 1 - src/node.cc | 7 ++----- src/platform.h | 2 +- src/platform_cygwin.cc | 3 +-- src/platform_darwin.cc | 3 +-- src/platform_freebsd.cc | 3 +-- src/platform_linux.cc | 3 +-- src/platform_none.cc | 3 +-- src/platform_openbsd.cc | 3 +-- src/platform_sunos.cc | 3 +-- src/platform_win32.cc | 3 +-- test/simple/test-memory-usage.js | 1 - 12 files changed, 11 insertions(+), 24 deletions(-) diff --git a/doc/api/process.markdown b/doc/api/process.markdown index 817a81d987..98b095caea 100644 --- a/doc/api/process.markdown +++ b/doc/api/process.markdown @@ -312,7 +312,6 @@ measured in bytes. This will generate: { rss: 4935680, - vsize: 41893888, heapTotal: 1826816, heapUsed: 650472 } diff --git a/src/node.cc b/src/node.cc index 4cfcb317b5..fc4f26edea 100644 --- a/src/node.cc +++ b/src/node.cc @@ -106,7 +106,6 @@ static Persistent errpath_symbol; static Persistent code_symbol; static Persistent rss_symbol; -static Persistent vsize_symbol; static Persistent heap_total_symbol; static Persistent heap_used_symbol; @@ -1582,9 +1581,9 @@ v8::Handle MemoryUsage(const v8::Arguments& args) { HandleScope scope; assert(args.Length() == 0); - size_t rss, vsize; + size_t rss; - int r = Platform::GetMemory(&rss, &vsize); + int r = Platform::GetMemory(&rss); if (r != 0) { return ThrowException(Exception::Error(String::New(strerror(errno)))); @@ -1594,13 +1593,11 @@ v8::Handle MemoryUsage(const v8::Arguments& args) { if (rss_symbol.IsEmpty()) { rss_symbol = NODE_PSYMBOL("rss"); - vsize_symbol = NODE_PSYMBOL("vsize"); heap_total_symbol = NODE_PSYMBOL("heapTotal"); heap_used_symbol = NODE_PSYMBOL("heapUsed"); } info->Set(rss_symbol, Integer::NewFromUnsigned(rss)); - info->Set(vsize_symbol, Integer::NewFromUnsigned(vsize)); // V8 memory usage HeapStatistics v8_heap_stats; diff --git a/src/platform.h b/src/platform.h index 8284bc188d..e89ebfaa6a 100644 --- a/src/platform.h +++ b/src/platform.h @@ -32,7 +32,7 @@ class Platform { static void SetProcessTitle(char *title); static const char* GetProcessTitle(int *len); - static int GetMemory(size_t *rss, size_t *vsize); + static int GetMemory(size_t *rss); static int GetCPUInfo(v8::Local *cpus); static double GetUptime(bool adjusted = false) { diff --git a/src/platform_cygwin.cc b/src/platform_cygwin.cc index d53e476a50..7a8c35f65f 100644 --- a/src/platform_cygwin.cc +++ b/src/platform_cygwin.cc @@ -167,7 +167,7 @@ const char* Platform::GetProcessTitle(int *len) { } -int Platform::GetMemory(size_t *rss, size_t *vsize) { +int Platform::GetMemory(size_t *rss) { FILE *f = fopen("/proc/self/stat", "r"); if (!f) return -1; @@ -222,7 +222,6 @@ int Platform::GetMemory(size_t *rss, size_t *vsize) { /* Virtual memory size */ if (fscanf (f, "%u ", &itmp) == 0) goto error; /* coverity[secure_coding] */ - *vsize = (size_t) itmp; /* Resident set size */ if (fscanf (f, "%u ", &itmp) == 0) goto error; /* coverity[secure_coding] */ diff --git a/src/platform_darwin.cc b/src/platform_darwin.cc index 49a34c4191..a196669eb7 100644 --- a/src/platform_darwin.cc +++ b/src/platform_darwin.cc @@ -71,7 +71,7 @@ const char* Platform::GetProcessTitle(int *len) { // Researched by Tim Becker and Michael Knight // http://blog.kuriositaet.de/?p=257 -int Platform::GetMemory(size_t *rss, size_t *vsize) { +int Platform::GetMemory(size_t *rss) { struct task_basic_info t_info; mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT; @@ -83,7 +83,6 @@ int Platform::GetMemory(size_t *rss, size_t *vsize) { if (r != KERN_SUCCESS) return -1; *rss = t_info.resident_size; - *vsize = t_info.virtual_size; return 0; } diff --git a/src/platform_freebsd.cc b/src/platform_freebsd.cc index e5822729ca..5b0e01e88e 100644 --- a/src/platform_freebsd.cc +++ b/src/platform_freebsd.cc @@ -66,7 +66,7 @@ const char* Platform::GetProcessTitle(int *len) { return NULL; } -int Platform::GetMemory(size_t *rss, size_t *vsize) { +int Platform::GetMemory(size_t *rss) { kvm_t *kd = NULL; struct kinfo_proc *kinfo = NULL; pid_t pid; @@ -82,7 +82,6 @@ int Platform::GetMemory(size_t *rss, size_t *vsize) { if (kinfo == NULL) goto error; *rss = kinfo->ki_rssize * page_size; - *vsize = kinfo->ki_size; kvm_close(kd); diff --git a/src/platform_linux.cc b/src/platform_linux.cc index 57e4e92c93..ae281606c0 100644 --- a/src/platform_linux.cc +++ b/src/platform_linux.cc @@ -125,7 +125,7 @@ const char* Platform::GetProcessTitle(int *len) { } -int Platform::GetMemory(size_t *rss, size_t *vsize) { +int Platform::GetMemory(size_t *rss) { FILE *f = fopen("/proc/self/stat", "r"); if (!f) return -1; @@ -195,7 +195,6 @@ int Platform::GetMemory(size_t *rss, size_t *vsize) { /* Virtual memory size */ if (fscanf (f, "%u ", &itmp) == 0) goto error; /* coverity[secure_coding] */ - *vsize = (size_t) itmp; /* Resident set size */ if (fscanf (f, "%u ", &itmp) == 0) goto error; /* coverity[secure_coding] */ diff --git a/src/platform_none.cc b/src/platform_none.cc index 6d92f03cf1..ea6125719b 100644 --- a/src/platform_none.cc +++ b/src/platform_none.cc @@ -42,10 +42,9 @@ const char* OS::GetProcessTitle(int *len) { } -int OS::GetMemory(size_t *rss, size_t *vsize) { +int OS::GetMemory(size_t *rss) { // Not implemented *rss = 0; - *vsize = 0; return 0; } diff --git a/src/platform_openbsd.cc b/src/platform_openbsd.cc index 1339558534..9399ad7acd 100644 --- a/src/platform_openbsd.cc +++ b/src/platform_openbsd.cc @@ -66,7 +66,7 @@ const char* Platform::GetProcessTitle(int *len) { return NULL; } -int Platform::GetMemory(size_t *rss, size_t *vsize) { +int Platform::GetMemory(size_t *rss) { kvm_t *kd = NULL; struct kinfo_proc2 *kinfo = NULL; pid_t pid; @@ -82,7 +82,6 @@ int Platform::GetMemory(size_t *rss, size_t *vsize) { if (kinfo == NULL) goto error; *rss = kinfo->p_vm_rssize * page_size; - *vsize = kinfo->p_uru_ixrss; kvm_close(kd); diff --git a/src/platform_sunos.cc b/src/platform_sunos.cc index 03450a545f..caac0a82c8 100644 --- a/src/platform_sunos.cc +++ b/src/platform_sunos.cc @@ -79,7 +79,7 @@ const char* Platform::GetProcessTitle(int *len) { } -int Platform::GetMemory(size_t *rss, size_t *vsize) { +int Platform::GetMemory(size_t *rss) { pid_t pid = getpid(); size_t page_size = getpagesize(); @@ -97,7 +97,6 @@ int Platform::GetMemory(size_t *rss, size_t *vsize) { /* XXX correct? */ - *vsize = (size_t) psinfo.pr_size * page_size; *rss = (size_t) psinfo.pr_rssize * 1024; fclose (f); diff --git a/src/platform_win32.cc b/src/platform_win32.cc index 699868c012..e948947544 100644 --- a/src/platform_win32.cc +++ b/src/platform_win32.cc @@ -198,7 +198,7 @@ const char* Platform::GetProcessTitle(int *len) { } -int Platform::GetMemory(size_t *rss, size_t *vsize) { +int Platform::GetMemory(size_t *rss) { HANDLE current_process = GetCurrentProcess(); PROCESS_MEMORY_COUNTERS pmc; @@ -209,7 +209,6 @@ int Platform::GetMemory(size_t *rss, size_t *vsize) { } *rss = pmc.WorkingSetSize; - *vsize = 0; // FIXME return 0; } diff --git a/test/simple/test-memory-usage.js b/test/simple/test-memory-usage.js index cf9a72f579..f123bc8c63 100644 --- a/test/simple/test-memory-usage.js +++ b/test/simple/test-memory-usage.js @@ -28,4 +28,3 @@ var assert = require('assert'); var r = process.memoryUsage(); console.log(common.inspect(r)); assert.equal(true, r['rss'] > 0); -assert.equal(true, r['vsize'] > 0);