Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove process.memoryUsage().vsize
Not meaningful cross platform; unused.
  • Loading branch information
ry committed Oct 18, 2011
1 parent d77ce4b commit 5783a52
Show file tree
Hide file tree
Showing 12 changed files with 11 additions and 24 deletions.
1 change: 0 additions & 1 deletion doc/api/process.markdown
Expand Up @@ -312,7 +312,6 @@ measured in bytes.
This will generate:

{ rss: 4935680,
vsize: 41893888,
heapTotal: 1826816,
heapUsed: 650472 }

Expand Down
7 changes: 2 additions & 5 deletions src/node.cc
Expand Up @@ -106,7 +106,6 @@ static Persistent<String> errpath_symbol;
static Persistent<String> code_symbol;

static Persistent<String> rss_symbol;
static Persistent<String> vsize_symbol;
static Persistent<String> heap_total_symbol;
static Persistent<String> heap_used_symbol;

Expand Down Expand Up @@ -1582,9 +1581,9 @@ v8::Handle<v8::Value> 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))));
Expand All @@ -1594,13 +1593,11 @@ v8::Handle<v8::Value> 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;
Expand Down
2 changes: 1 addition & 1 deletion src/platform.h
Expand Up @@ -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<v8::Array> *cpus);
static double GetUptime(bool adjusted = false)
{
Expand Down
3 changes: 1 addition & 2 deletions src/platform_cygwin.cc
Expand Up @@ -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;

Expand Down Expand Up @@ -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] */
Expand Down
3 changes: 1 addition & 2 deletions src/platform_darwin.cc
Expand Up @@ -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;

Expand All @@ -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;
}
Expand Down
3 changes: 1 addition & 2 deletions src/platform_freebsd.cc
Expand Up @@ -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;
Expand All @@ -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);

Expand Down
3 changes: 1 addition & 2 deletions src/platform_linux.cc
Expand Up @@ -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;

Expand Down Expand Up @@ -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] */
Expand Down
3 changes: 1 addition & 2 deletions src/platform_none.cc
Expand Up @@ -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;
}

Expand Down
3 changes: 1 addition & 2 deletions src/platform_openbsd.cc
Expand Up @@ -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;
Expand All @@ -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);

Expand Down
3 changes: 1 addition & 2 deletions src/platform_sunos.cc
Expand Up @@ -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();
Expand All @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/platform_win32.cc
Expand Up @@ -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;
Expand All @@ -209,7 +209,6 @@ int Platform::GetMemory(size_t *rss, size_t *vsize) {
}

*rss = pmc.WorkingSetSize;
*vsize = 0; // FIXME

return 0;
}
Expand Down
1 change: 0 additions & 1 deletion test/simple/test-memory-usage.js
Expand Up @@ -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);

0 comments on commit 5783a52

Please sign in to comment.