Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added some win32 platform functions #1617

Closed
wants to merge 1 commit into from

2 participants

@Skomski

No description provided.

@ry
ry commented

Before we can accept your patch (which upon first glance looks good) you need to agree to our contributor agreement http://nodejs.org/cla.html

@Skomski

Done.

@ry ry closed this pull request from a commit
@Skomski Skomski Added some win32 platform functions
Fixes #1617
65c2763
@ry ry closed this in 65c2763
@ry
ry commented

thanks. vsize isn't correct setting to zero. see also joyent/libuv#140

@Skomski Skomski referenced this pull request from a commit
@Skomski Skomski Added some win32 platform functions
Fixes #1617
3a55b50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 31, 2011
  1. @Skomski
This page is out of date. Refresh to see the latest.
Showing with 33 additions and 5 deletions.
  1. +33 −5 src/platform_win32.cc
View
38 src/platform_win32.cc
@@ -198,18 +198,46 @@ const char* Platform::GetProcessTitle(int *len) {
int Platform::GetMemory(size_t *rss, size_t *vsize) {
- *rss = 0;
- *vsize = 0;
+
+ HANDLE current_process = GetCurrentProcess();
+ PROCESS_MEMORY_COUNTERS pmc;
+
+ if ( !GetProcessMemoryInfo( current_process, &pmc, sizeof(pmc)) )
+ {
+ winapi_perror("GetProcessMemoryInfo");
+ }
+
+ *rss = pmc.WorkingSetSize;
+ *vsize = pmc.PeakWorkingSetSize;
+
return 0;
}
double Platform::GetFreeMemory() {
- return -1;
+
+ MEMORYSTATUSEX memory_status;
+ memory_status.dwLength = sizeof(memory_status);
+
+ if(!GlobalMemoryStatusEx(&memory_status))
+ {
+ winapi_perror("GlobalMemoryStatusEx");
+ }
+
+ return (double)memory_status.ullAvailPhys;
}
double Platform::GetTotalMemory() {
- return -1;
+
+ MEMORYSTATUSEX memory_status;
+ memory_status.dwLength = sizeof(memory_status);
+
+ if(!GlobalMemoryStatusEx(&memory_status))
+ {
+ winapi_perror("GlobalMemoryStatusEx");
+ }
+
+ return (double)memory_status.ullTotalPhys;
}
@@ -219,7 +247,7 @@ int Platform::GetCPUInfo(Local<Array> *cpus) {
double Platform::GetUptimeImpl() {
- return -1;
+ return (double)GetTickCount()/1000.0;
}
int Platform::GetLoadAvg(Local<Array> *loads) {
Something went wrong with that request. Please try again.