You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.4 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Author: David Robert Nadeau
  3. * Site: http://NadeauSoftware.com/
  4. * License: Creative Commons Attribution 3.0 Unported License
  5. * http://creativecommons.org/licenses/by/3.0/deed.en_US
  6. */
  7. #if ! defined(DEBUG) && defined(SKIP_MEM_CHECK)
  8. #include <cstddef>
  9. size_t getPeakRSS();
  10. size_t getCurrentRSS();
  11. #else
  12. #if defined(_WIN32)
  13. #include <psapi.h>
  14. #include <windows.h>
  15. #elif defined(__linux__) || defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__))
  16. #include <sys/resource.h>
  17. #include <unistd.h>
  18. #if defined(__APPLE__) && defined(__MACH__)
  19. #include <mach/mach.h>
  20. #elif (defined(_AIX) || defined(__TOS__AIX__)) || (defined(__sun__) || defined(__sun) || defined(sun) && (defined(__SVR4) || defined(__svr4__)))
  21. #include <fcntl.h>
  22. #include <procfs.h>
  23. #elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__)
  24. #include <cstddef>
  25. #include <stdio.h>
  26. #endif
  27. #else
  28. #error "Cannot define getPeakRSS( ) or getCurrentRSS( ) for an unknown OS."
  29. #endif
  30. /**
  31. * Returns the peak (maximum so far) resident set size (physical
  32. * memory use) measured in bytes, or zero if the value cannot be
  33. * determined on this OS.
  34. */
  35. size_t getPeakRSS();
  36. /**
  37. * Returns the current resident set size (physical memory use) measured
  38. * in bytes, or zero if the value cannot be determined on this OS.
  39. */
  40. size_t getCurrentRSS();
  41. #endif // DEBUG