Further to my earlier post of a memory leak and 'blaming' the CSLA framework I know have found out that this may be a pure Windows problem.
The problem is - and let me focus on the CSLA part - that when you repeatedly call for a Business Object (BO) that collects its data from various sources and passes it back to the client the memory you use increase. However, when this BO goes out of scope (and you do the Dispose() etc.) you would expect the memory to have gone down to what it was before.
However, what happens here is that I am having to repeatedly call a BO which therefore causes my app to run eventually out of memory.
A remarkable thing to note is that if you minimise and then restore the app it will bring the memory right down again - and so it continues.
The amazing thing is that this seems to apply to all Windows apps. Start Word, type away, check the Task Manager's memory consumption for this app, now minimise/restore the app and the memory will have come right down.
This behaviour seems to be known (http://www.dotnet247.com/247reference/msgs/35/178959.aspx) but what I don't understand is that this phenomenon is killing my app so this MUST also happen to other people!
Has anyone got any suggestions?
Cheers
Marcel.
Need some clarification here.
First, you wouldn't normally need to implement Dispose() in a BO. Do you have an unusual BO?
Are you using .NET 2.0? According to the link you gave it seems the options are either upgrading to 2.0 or coding some memory management (UGH!) into this stuff you're writing.
Thanks for the quick reply Rockford! After more than a day checking all sorts I found that the problem is probably with the Oracle driver I am using - vs.10.2.0.100. This driver loses memory in the following scenario:
A business object has returned a DataSet to the client. Sending this DataSet directly back to the database seems to cause the leak!! I store the DataSet readymade as a BLOB in the database (for good reasons!! - since I may have manipulated and added lots of additional disparate data into the DataSet).
Wrong code (causes the memory leak): 'Reports' is the BusinessObject
DataSet ds = Reports.ReportRunGetOwnerInfo(EntityType, EntityCode).Results; // retrieves the data
Reports.SaveBlobReturnKey(ds); // saves the DataSet as a blob
Correct code (no leak)
DataSet ds = Reports.ReportRunGetOwnerInfo(EntityType, EntityCode).Results;
DataTable dtTmp = ds.Tables[0];
ds.Tables.Remove(dtTmp);
DataSet dsNew = new DataSet();
dsNew.Tables.Add(dtTmp);
Reports.SaveBlobReturnKey(dsNew);
Can you or anyone shine a light on what might be happening here?
Cheers
Marcel
mheere:However, when this BO goes out of scope (and you do the Dispose() etc.) you would expect the memory to have gone down to what it was before.
mheere:However, what happens here is that I am having to repeatedly call a BO which therefore causes my app to run eventually out of memory.
Are you actually getting an out of memory exception?
mheere:A remarkable thing to note is that if you minimise and then restore the app it will bring the memory right down again - and so it continues.The amazing thing is that this seems to apply to all Windows apps.
This is true of all windows applications and as far as I know is by design. The amount of memory actually doesn't change; the amount of working memory does.
mheere:Start Word, type away, check the Task Manager's memory consumption for this app, now minimise/restore the app and the memory will have come right down.
Ahhh!! Task Manager is NOT a valid way to determine how much memory an application is using. This is well documented.
mheere:This behaviour seems to be known (http://www.dotnet247.com/247reference/msgs/35/178959.aspx) but what I don't understand is that this phenomenon is killing my app so this MUST also happen to other people!
If your application is running out of memory, its likely because somewhere, somehow you're not disposing of IDisposable objects properly, and / or you aren't releasing all references to objects (Csla based or not) you are using. Check with a fine toothed comb.
HTHCopyright (c) Marimer LLC