Memory leak issues

Memory leak issues

Old forum URL: forums.lhotka.net/forums/t/4579.aspx


Marjon1 posted on Friday, March 28, 2008

Hi,

I'm having some serious memory leak issues with our business objects, and I can't seem to identify where they could be coming from. It appears to be something with our use of CSLA, though I do not blame CSLA itself. I need the collective wisdom of these forums to try and identify the source. We are running version 3.0.x with a few customizations to the CSLA base (overrides to specific methods, to send the object to another service on save). What I've identified so far:

 - Using a specilaised object that has minimal properties and one readonly list and one editable list at the base object level, creating this object, setting the two properties and then saving causes a very step climb in memory usage which NEVER drops, even with garbage collection. This is done in a console app. The children objects are empty for these tests.

- Performing the exact same code, not using these objects and inserting the values into the database using the same SQL code as simple objects results in a straight line of memory use with the profiler.\

Our object model looks like this:

BusinessBase -> PredatorBusinessBase -> BusinessObject -> Product

PredatorBusinessBase is our base object with CanRead, CanWrite, and mostly over static methods that all our objects come from. This object has no properties.

I've tried putting NotUndoable attribute on the lists, which on the product is about 5 editable lists (which in our tests are all empty!). As we don't use N-Level Undo, but this doesn't appear to have made any difference. We only really noticed this memory issues when testing an import routine with about 10,000 objects being created and saved.

Any feedback or suggestions would be greatly appreciated.

Thanks in advance

ajj3085 replied on Friday, March 28, 2008

Are you sure your objects still aren't being referenced somewhere?  It's possible that if you didn't unhook an event handler from a BO a reference is still being kept alive.  Also, are you sure there's really a memory like?  The Csharp newsgroups are littered with posts about people that think they have memory leaks when they don't.  I think part of is that you can ask the garbage collector to run but it really won't collect memory until IT deems it necessary... that is you request more memory from the heap and the only way to get that memory is for objects to finally be collected.

FatPigeon replied on Friday, March 28, 2008

Have you tried http://www.red-gate.com/products/ants_profiler/

Yang replied on Friday, March 28, 2008

This was one of our biggest issues before. We have investigated some memory profilers and have eventually purchased the MemProfiler. Anyway, at first glance the issues where CSLA based but digging deeper, we found out that all of them were caused by not disposing the DBCommand objects. Also, if you are using ODP.NET, you need to dispose off the OracleParameters after every call to the database. Unlike other DBParameter implementations, OracleParameters are disposable. Not disposing off the OracleParameters was the source of 95% of our memory leak. Hope this helps.

Copyright (c) Marimer LLC