Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix broken os.freemem() on FreeBSD amd64 #1428

Closed
wants to merge 1 commit into from

2 participants

@avz

v_free_count defined as u_int v_free_count (struct vmmeter sys/vmmeter.h:87), but variable info defined as unsigned long, that cause error on 64-bits systems because higher 32 bits remain uninitialized.

Example:

require('os').freemem()
140737549713408

@avz avz v_free_count defined as u_int v_free_count (struct vmmeter sys/vmmete…
…r.h:87), but variable info defined as unsigned long, this cause error on 64-bits systems because higher 32 bits remain uninitialized
2624dfb
@bnoordhuis

Good catch. I suspect this is broken in Platform::GetTotalMemory() (and perhaps others) too?

@avz

No, Platform::GetTotalMemory() work fine - hw.physmem defined as unsigned long: { "physmem", CTLTYPE_ULONG }. And all other Platform::* working properly on my FreeBSD 8.2 amd64

@bnoordhuis

Landed in a38bda9. Thanks!

@bnoordhuis bnoordhuis closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 30, 2011
  1. @avz

    v_free_count defined as u_int v_free_count (struct vmmeter sys/vmmete…

    avz authored
    …r.h:87), but variable info defined as unsigned long, this cause error on 64-bits systems because higher 32 bits remain uninitialized
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  src/platform_freebsd.cc
View
2  src/platform_freebsd.cc
@@ -156,7 +156,7 @@ int Platform::GetCPUInfo(Local<Array> *cpus) {
double Platform::GetFreeMemory() {
double pagesize = static_cast<double>(sysconf(_SC_PAGESIZE));
- unsigned long info;
+ unsigned int info = 0;
size_t size = sizeof(info);
if (sysctlbyname("vm.stats.vm.v_free_count", &info, &size, NULL, 0) < 0) {
Something went wrong with that request. Please try again.