|
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'
|
|
From: Nicholas N. <nj...@ca...> - 2005-01-10 20:45:08
|
On Mon, 10 Jan 2005, Piotr [iso-8859-2] Pi=B1tkowski wrote: > Maybe someone has already prepared such patch? Or should I try to make it > myself? Someone has written a patch, it may be somewhere in the bugs database --=20 have a search there (see valgrind.kde.org/bugs.html). N |
|
From: Piotr <ko...@ad...> - 2005-01-11 09:51:35
|
On Mon, Jan 10, 2005 at 08:45:03PM +0000, Nicholas Nethercote wrote: > On Mon, 10 Jan 2005, Piotr [iso-8859-2] Pi?tkowski wrote: >=20 > >Maybe someone has already prepared such patch? Or should I try to ma= ke it > >myself? >=20 > Someone has written a patch, it may be somewhere in the bugs database= --=20 > have a search there (see valgrind.kde.org/bugs.html). Thank you, I've found it and I fixed this patch to compile with version 2.2.0 - looks that it works fine: http://bugs.kde.org/show_bug.cgi?id=3D72649#c2 Why isn't it included in the official distribution? --=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' |