OutOfMemory exception

Posts   
 
    
JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 07-Apr-2010 00:21:47   

Hi,

I am getting a System.OutOfMemory exception on a xxxxxx.Save(true); I use the SelfServicing variant of LLBLGen 2.6.

Is it possible to free space after the xxxxxx.Save(true) ? If so, how?

Best regards,

Jan

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 07-Apr-2010 08:14:45   

Hi Jan,

Could you please post more info so we can understand better the problem?

  • LLBLGen runtime library version
  • Exception message and stack trace
  • Conditions that trigger the exception (amount of data saved, how large is the graph, inheritance?, custom code)
David Elizondo | LLBLGen Support Team
JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 07-Apr-2010 09:41:59   

Hi David,

This is found in the output:

A first chance exception of type 'System.OutOfMemoryException' occurred in SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>SXXPlantJobMonitor.vshost.exe</AppDomain><Exception><ExceptionType>System.OutOfMemoryException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Exception of type 'System.OutOfMemoryException' was thrown.</Message><StackTrace> at SD.LLBLGen.Pro.ORMSupportClasses.ObjectGraphUtils.GetOrCreateAdjacencyList[TEntity](Guid objectId, Dictionary`2 adjacencyLists)

I'm using the latest version of LLBLGen 2.6.

When I look at the resource usage in the taskmanager, the physical memory used increases during the run of the program and stops when the maximum avaialble is reached. Near 2GB on a 2GB VM (Windows server 2003 Standard, SP2)). The database is on a separate server.

The updates to the database are done in a foreach loop. I have the impression that the garbage collection is not freeing all the resources needed in an update.

I would not know how to determine the condition that trigger the exception. Where can I find the amount of data saved or the graph?

JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 07-Apr-2010 10:28:26   

I solved the problem.

Somewhere in the code I used something like XXX.YYY[0]. Here XXX and YYY are entities in the database having a 1:n relation

I changed this by not using YYY[0], but retrieving a collection (GetMulti(filter,1).

Apparently using the first entry in a collection like this causus all YYY that have a relation with XXX to be held somewhere in memory.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39866
Joined: 17-Aug-2003
# Posted on: 07-Apr-2010 10:42:28   

indeed, a reverse relationship (Customer.Orders is the reverse of Order.Customer) keeps objects in memory, so you've to be careful about that when doing things in a loop.

Frans Bouma | Lead developer LLBLGen Pro