mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 19:48:20 +00:00
avoid potentially expensive mallinfo() call if result won't be used
This commit is contained in:
parent
5402f22d48
commit
f88862f6ce
1 changed files with 6 additions and 3 deletions
|
@ -2182,13 +2182,14 @@ void get_memory_usage(uint64_t* total, uint64_t* malloced) {
|
|||
uint64_t ret_total;
|
||||
|
||||
#if defined(HAVE_MALLINFO2) || defined(HAVE_MALLINFO)
|
||||
if ( malloced ) {
|
||||
#ifdef HAVE_MALLINFO2
|
||||
struct mallinfo2 mi = mallinfo2();
|
||||
struct mallinfo2 mi = mallinfo2();
|
||||
#else
|
||||
struct mallinfo mi = mallinfo();
|
||||
struct mallinfo mi = mallinfo();
|
||||
#endif
|
||||
if ( malloced )
|
||||
*malloced = mi.uordblks;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DARWIN
|
||||
|
@ -2207,6 +2208,8 @@ void get_memory_usage(uint64_t* total, uint64_t* malloced) {
|
|||
ret_total = r.ru_maxrss * 1024;
|
||||
|
||||
if ( malloced )
|
||||
// This will overwrite any mallinfo[2] value from above, should
|
||||
// be restructured to avoid unnecessary work.
|
||||
*malloced = r.ru_ixrss * 1024;
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue