-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathw3getmem.c
59 lines (51 loc) · 3.02 KB
/
w3getmem.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* ------------------------------------------------------------------ */
/* function get_memory() */
/* */
/* +-----------------------------------+ */
/* | WAVEWATCH III NOAA/NCEP | */
/* | H. L. Tolman | */
/* | C | */
/* | Last update : 28-Jan-2014 | */
/* +-----------------------------------+ */
/* */
/* 28-Jan-2014 : Origination. ( version 5.00 ) */
/* */
/* 1. Purpose : */
/* */
/* Get memory use HWM in Mb for profiling purposes. */
/* */
/* 2. Method : */
/* */
/* C system calls, based on code mostly form Jim Abeles, provided */
/* by George Vandenberghe. */
/* */
/* 3. Parameters : */
/* */
/* 4. Subroutines used : */
/* */
/* 5. Called by : */
/* */
/* 6. Error messages : */
/* */
/* 7. Remarks : */
/* */
/* 8. Structure : */
/* */
/* See source code. */
/* */
/* 9. Source code : */
/* */
/* ------------------------------------------------------------------ */
#include <stdio.h>
#include <sys/resource.h>
double get_memory_(void)
{
long Kbytes;
double Mbytes;
struct rusage RU;
getrusage(RUSAGE_SELF, &RU);
Kbytes = RU.ru_maxrss;
Mbytes = ((double) Kbytes) / 1024.0;
return Mbytes;
}
/* End of get_memory ------------------------------------------------ */