Hello,

I recently was charged in fixing memory leak problem in our products.
We use xerces 2.8.0 on Windows platform.
The problem was that when some xerces objects were created or retrieved by 
getDocument(), for example, memory footprint of xerces uses increased.

I know that "memory leak is not real" in the memory management scheme of xerces.
Anyway, it is memory pool based, and probably it is reference counted. 
When there is released memory in the memory pool ( which is not really 
released, but the memory management scheme of xerces treats those as released), 
and when a new request to create some object is issued, the memory manager 
should return some of its "deallocated" space to the caller if the "free" 
memory space is enough for the request. If there is no enough "free space", it 
is perfectly OK to increase memory space which the manager handles and return 
it.

However, what I found out was that it keeps increasing the memory pool.
Our program can run for more than 1 week or months. And someone who wrote that 
used MS's MultiDocumentTemplate scheme and when view/document/frame pairs are 
registered, it creates some xerces object with "Initialize()" method, which is 
to initialized the memory manager" ( I believe this manager is so called pseudo 
garbage collector like Objective-C's. ) However, it doesn't call the 
"Terminate()" function, because it is optional and if an app quits, anyway the 
memory pool is collected and cleaned up.
However, because our app can run for many days, instead of collecting unused 
space and freeing them up, it just increase its memory foot print.

So, I tried searching if there is a function like "Compact()" or anything which 
really frees "free space".
However, I couldn't find one. According to our scenario, it is better to have 
such functionality.
So, I modified our source code to call the "initalize()" and "Terminate()" 
function at will to clean up the memory to reduce memory foot print.

So, I would like to suggest some member functions to compact the memory pool at 
will.
Or, just like Objective-C/Cocoa, it would be great if it automatically collect 
them under certain condition.
( it seems to collect free space at every RunLoop firing? )
Also, yeah.. it should provide explicit compaction.

What do you think about this?
Some of you may say that "Initialize()" and "Terminate()" whenever you start 
using xcerces and stop using it. Yeah.. you are right, but there are some cases 
where it is not suitable.
( Actually I think I can use xerces without causing this problem, but some 
programmers who don't even try to understand memory management scheme enough 
just write codes and put it in production codes. I would call them *****, but 
we should admit that there will be such people. )

Thank you.





---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to