library: finally circumvent libnuma memory leak <stat>
Still unhappy with a minor memory leak associated with libnuma, I experimented with omitting the dlclose that was issued at module's end. For some reason which will remain a mystery, the valgrind leak then went bye-bye. So this patch just omits one use of dlclose and relies on whatever kernel magic is at work to free the memory when each process ends. We kept, however, the original code (now commented-out) to serve as a future caution. There remains one potential (but unlikely) dlclose use near the original dlopen. But there will be no leak as that 'numa_node_of_cpu' will not yet have been called. This seems to be the culprit that triggers such leaks. None of this libnuma shit would likely have come close to hitting our fan had the numa developers provided us with 'new' and 'unref' functions like our newlib does. Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
a8f7e44233
commit
91d47123f2
24
proc/stat.c
24
proc/stat.c
@ -489,15 +489,7 @@ static int stat_make_numa_hist (
|
|||||||
nod_ptr->new.irq += cpu_ptr->new.irq; nod_ptr->old.irq += cpu_ptr->old.irq;
|
nod_ptr->new.irq += cpu_ptr->new.irq; nod_ptr->old.irq += cpu_ptr->old.irq;
|
||||||
nod_ptr->new.sirq += cpu_ptr->new.sirq; nod_ptr->old.sirq += cpu_ptr->old.sirq;
|
nod_ptr->new.sirq += cpu_ptr->new.sirq; nod_ptr->old.sirq += cpu_ptr->old.sirq;
|
||||||
nod_ptr->new.stolen += cpu_ptr->new.stolen; nod_ptr->old.stolen += cpu_ptr->old.stolen;
|
nod_ptr->new.stolen += cpu_ptr->new.stolen; nod_ptr->old.stolen += cpu_ptr->old.stolen;
|
||||||
/*
|
|
||||||
* note: the above call to 'our_node_of_cpu' will produce a modest
|
|
||||||
* memory leak summarized as:
|
|
||||||
* ==1234== LEAK SUMMARY:
|
|
||||||
* ==1234== definitely lost: 512 bytes in 1 blocks
|
|
||||||
* ==1234== indirectly lost: 48 bytes in 2 blocks
|
|
||||||
* ==1234== ...
|
|
||||||
* [ thanks very much libnuma, for all the pain you've caused us ]
|
|
||||||
*/
|
|
||||||
cpu_ptr->numa_node = node;
|
cpu_ptr->numa_node = node;
|
||||||
nod_ptr->id = node;
|
nod_ptr->id = node;
|
||||||
}
|
}
|
||||||
@ -867,6 +859,8 @@ PROCPS_EXPORT int procps_stat_new (
|
|||||||
if (p->our_max_node && p->our_node_of_cpu)
|
if (p->our_max_node && p->our_node_of_cpu)
|
||||||
p->nodes.total = p->our_max_node() + 1;
|
p->nodes.total = p->our_max_node() + 1;
|
||||||
else {
|
else {
|
||||||
|
// this dlclose is safe - we've yet to call numa_node_of_cpu
|
||||||
|
// ( there's one other dlclose which has now been disabled )
|
||||||
dlclose(p->libnuma_handle);
|
dlclose(p->libnuma_handle);
|
||||||
p->libnuma_handle = NULL;
|
p->libnuma_handle = NULL;
|
||||||
}
|
}
|
||||||
@ -934,8 +928,16 @@ PROCPS_EXPORT int procps_stat_unref (
|
|||||||
|
|
||||||
#ifndef NUMA_DISABLE
|
#ifndef NUMA_DISABLE
|
||||||
#ifndef PRETEND_NUMA
|
#ifndef PRETEND_NUMA
|
||||||
if ((*info)->libnuma_handle)
|
/* note: we'll skip a dlcose() to avoid the following libnuma memory
|
||||||
dlclose((*info)->libnuma_handle);
|
* leak which is triggered after a call to numa_node_of_cpu():
|
||||||
|
* ==1234== LEAK SUMMARY:
|
||||||
|
* ==1234== definitely lost: 512 bytes in 1 blocks
|
||||||
|
* ==1234== indirectly lost: 48 bytes in 2 blocks
|
||||||
|
* ==1234== ...
|
||||||
|
* [ thanks very much libnuma, for all the pain you've caused ]
|
||||||
|
*/
|
||||||
|
// if ((*info)->libnuma_handle)
|
||||||
|
// dlclose((*info)->libnuma_handle);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
free(*info);
|
free(*info);
|
||||||
|
Loading…
Reference in New Issue
Block a user