|
From: Piotr <ko...@ad...> - 2005-01-10 14:44:22
|
I was really disappointed today, when I've realised that valgrind doesn=
't
detect memory leaks with cyclic references.=20
Example:
void do_leak() {
void **p =3D (void**)malloc( 1024 );
p[0] =3D p;
}
int main() {
while( 1 ) {
do_leak();
sleep( 1 );
}
}
=2E..and leak report:
=3D=3D25900=3D=3D LEAK SUMMARY:
=3D=3D25900=3D=3D definitely lost: 0 bytes in 0 blocks.
=3D=3D25900=3D=3D possibly lost: 0 bytes in 0 blocks.
=3D=3D25900=3D=3D still reachable: 5120 bytes in 5 blocks.
=3D=3D25900=3D=3D suppressed: 0 bytes in 0 blocks.
Of course, this is exactly as is stated in docs, nevertheless I need th=
e
option of reporting such leaks - this doesn't look very complicated, ju=
st
during searching for pointers to allocated memory regions, one should c=
heck
if pointers to some memory region are defined only in this region, then
treat such region as not reachable (and then repeat this process for
regions, which has pointers only in this - not reachable - region, and =
so
on).
Maybe someone has already prepared such patch? Or should I try to make =
it
myself?
--=20
Piotr Pi=B1tkowski, Onet.pl SA, Krak=F3w [=
PT/SH]
perl -le 's**02).4&\*534^[./4(%2^0%2,^([#+%2&**y%& -;^[%"`-{ a%%s%%$_%e=
e'
|