[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Are KParts leaking? [Re: What happened to KStaticDeleter]
From:       Andras Mantia <amantia () kde ! org>
Date:       2007-10-03 8:00:44
Message-ID: 200710031100.45777.amantia () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


On Wednesday 03 October 2007, Andras Mantia wrote:
> I may do some detailed Valgrind tests to see if this really happens.
> Of course, the app could leak in other places as well, so it's not so
> easy to blame the kpart handling if valgrind reports some leaks.

Here are the results. The test is: start quanta, open 1 editor tab, 
close it. Start again, open 10 tabs, close 9 of it, open another 9 tabs 
and close quanta. Run with valgrind --leak-check=full, but I'm not sure 
it worked, as valgrind gave me this error at the end of every run:

Memcheck: mc_leakcheck.c:817 (vgMemCheck_do_detect_memory_leaks): 
Assertion 'lc_shadows[i]->data + lc_shadows[i]->size <= 
lc_shadows[i+1]->data' failed.
==2420==    at 0x38017803: 
(within /usr/lib64/valgrind/amd64-linux/memcheck)
==2420==    by 0x389A7387: ???
==2420==    by 0x389A58F7: ???
==2420==    by 0x3808AD8C: 
(within /usr/lib64/valgrind/amd64-linux/memcheck)
==2420==    by 0x402CC82BF: ???
==2420==    by 0x3808C72E: 
(within /usr/lib64/valgrind/amd64-linux/memcheck)


The results when opening only one tab:
==2353==
==2353== ERROR SUMMARY: 35 errors from 30 contexts (suppressed: 398 from 
5)
==2353== malloc/free: in use at exit: 3,555,541 bytes in 46,951 blocks.
==2353== malloc/free: 3,457,846 allocs, 3,410,893 frees, 163,022,201 
bytes allocated.
==2353== For counts of detected errors, rerun with: -v

For 10 tabs, 9 closed, 9 opened:
==2420==
==2420== ERROR SUMMARY: 35 errors from 30 contexts (suppressed: 830 from 
5)
==2420== malloc/free: in use at exit: 3,532,802 bytes in 47,073 blocks.
==2420== malloc/free: 6,030,222 allocs, 5,983,147 frees, 261,379,461 
bytes allocated.
==2420== For counts of detected errors, rerun with: -v


Strange that for the second case its actually less memory used at exit. 
Regarding the number of allocs/frees, in first case the difference is 
46953, while in the second case it is 47075, relatively close numbers.


I repeated the test with the difference, that I did not exit Quanta, but 
canceled it (with CTRL-C in valgrind), so I can see the exact usage at 
the time when 1 tab is opened, 10 tabs are opened and 1 tab is opened 
(10 tabs were opened, 9 closed):

1 tab opened:
==2548==
==2548== ERROR SUMMARY: 35 errors from 30 contexts (suppressed: 334 from 
5)
==2548== malloc/free: in use at exit: 13,531,505 bytes in 262,804 
blocks.
==2548== malloc/free: 2,992,486 allocs, 2,729,680 frees, 145,367,169 
bytes allocated.
==2548== For counts of detected errors, rerun with: -v

10 tabs opened:
==2596==
==2596== ERROR SUMMARY: 35 errors from 30 contexts (suppressed: 482 from 
6)
==2596== malloc/free: in use at exit: 18,216,682 bytes in 355,235 
blocks.
==2596== malloc/free: 3,838,653 allocs, 3,483,416 frees, 178,505,210 
bytes allocated.
==2596== For counts of detected errors, rerun with: -v

1 tab opened (10 opened, 9 closed):
==2616==
==2616== ERROR SUMMARY: 35 errors from 30 contexts (suppressed: 619 from 
6)
==2616== malloc/free: in use at exit: 13,612,569 bytes in 264,494 
blocks.
==2616== malloc/free: 4,556,565 allocs, 4,292,069 frees, 204,574,202 
bytes allocated.
==2616== For counts of detected errors, rerun with: -v

The memory usage in the 1st and 3rd case is quite close, while it is 
clearly visible in case 2 that the 9 extra tabs require quite some 
memory.


 Assuming that the application might leak in other places as well 
(Quanta code, KMDI code -eg. all the errors from the summary are from 
KMDI, Katepart code, kdelibs code), my conclusion is that the memory is 
freed correctly when deleting the KPart (katepart) objects. If others 
have other opinion (wrong test, wrong interpretation), let me know how 
should I really do this test.

Andras

-- 
Quanta Plus developer - http://quanta.kdewebdev.org
K Desktop Environment - http://www.kde.org

["signature.asc" (application/pgp-signature)]

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic