On 24.07.2012 17:59, Rob Weir wrote:
On Mon, Jul 23, 2012 at 10:55 PM, Linyi Li <lilinyi921...@gmail.com> wrote:
It is a good suggestion to test memory leak. Maybe we can write some test
cases based on memory leak defect.

Yes, that is a good idea. The valgrind tool could be very helpful for such an automated test.

It is tricky.  For example, a dialog box might have a memory leak when
you click "cancel" but not when you click "OK" to exit it.  The leak
can depend on the exact steps taken by the user and the exact path
through the code.  We can never test all paths.

Yes. It gets even more tricky when caches come into play. E.g. a spellchecker may cache some parts of the dictionary depending on the documents it already parsed.

Adding support for a memleak-checker friendly mode to such caches can help here though. If this mode is enabled they will discard unused entries as soon as possible.

Maybe one of the long-time OpenOffice developers know an answer to
this:  Have we ever considered having a custom memory allocator with a
separate pool of memory for each loaded document?

IIRC they are already here and were called "rtl_arena" or "rtl_cache". Please see main/sal/inc/rtl/alloc.h for details.

Also there were specialized memory allocators based on them but using different ones (e.g. by using the "--with-alloc" configure option) AFAIK didn't hurt the performance too much.

That way, when we
close a document we can just free the entire block and avoid any
memory leaks?  We did this with SmartSuite years ago, and it was a big
help.

This looks like an interesting idea.

Herbert

Reply via email to