File tree 1 file changed +25
-3
lines changed
1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change 7
7
#if !defined(INSIDE_ENCLAVE) || defined(VIRTUAL_ENCLAVE)
8
8
# include < cstring>
9
9
# include < limits>
10
+ # include < sys/resource.h>
10
11
#else
11
12
# include " ccf/pal/hardware_info.h"
12
13
@@ -36,9 +37,30 @@ namespace ccf::pal
36
37
37
38
static inline bool get_mallinfo (MallocInfo& info)
38
39
{
39
- info.max_total_heap_size = std::numeric_limits<size_t >::max ();
40
- info.current_allocated_heap_size = 0 ;
41
- info.peak_allocated_heap_size = 0 ;
40
+ {
41
+ rusage ru;
42
+ auto rc = getrusage (RUSAGE_SELF, &ru);
43
+ if (rc != 0 )
44
+ {
45
+ return false ;
46
+ }
47
+ const auto heap_size = ru.ru_maxrss * 1024 ;
48
+
49
+ info.current_allocated_heap_size = heap_size;
50
+ info.peak_allocated_heap_size = heap_size;
51
+ }
52
+
53
+ {
54
+ rlimit rl;
55
+ auto rc = getrlimit (RLIMIT_AS, &rl);
56
+ if (rc != 0 )
57
+ {
58
+ return false ;
59
+ }
60
+
61
+ info.max_total_heap_size = rl.rlim_cur ;
62
+ }
63
+
42
64
return true ;
43
65
}
44
66
You can’t perform that action at this time.
0 commit comments