Event.Summary.memoryUsageMb in the ROOT output is always zero

Issue #274 resolved
Former user created an issue

Offending section, BDSUtilities.cc, line 550:

G4double BDS::GetMemoryUsage()
{
  struct rusage r_usage;
  G4double result = getrusage(RUSAGE_SELF,&r_usage);
  return result;
}

This is because instead of returning the ru_maxrss attribute of the rusage instance passed by reference, we are simply returning the return code of the getrusage, which will in general be 0. This was broken in 37d23c3c. However even the old implementation was buggy as it does not work across platforms. On MacOS ru_maxrss is in unites of bytes, (do man getrusage on your macbook), whereas according to the linux manual http://man7.org/linux/man-pages/man2/getrusage.2.html, on linux it is in kilobytes. We can detect which OS we’re on with the compiler-provided macros detailed here:

http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system

Comments (3)

  1. Laurie Nevay

    Correct! Please fix Stuart as you’ve worked it out.

    src/BDSUtilities.hh already has usage of __APPLE__ in the includes.

    Thanks,

    Laurie

  2. Log in to comment