G
Guest
Hello
I am struggeling with a 'OutOfMemoryException' and would very much like some
help to find out why this is happening.
In the GC class there is a method called ‘GetTotalMemory’.
(http://msdn2.microsoft.com/en-us/library/system.gc.gettotalmemory.aspx) .
According to the documentation this method
“Retrieves the number of bytes currently thought to be allocatedâ€
My understanding is that this method returns the number of bytes that the
process is currently using.
Further, my understanding is that in Windows CE 5.0 each process is limited
to a maximum of 32MB of memory.
My application has approximately 4MB of embedded resources (all of which are
images) that are inclued in the .exe file.
When the application starts I assume that these files are loaded into RAM.
When calling the ‘GetTotalMemory’ just after the main Window or Form has
been displayed, this method returns approximately 4MB, so this seems to
correspond well.
In my program I have added the following piece of code:
catch (OutOfMemoryException OOM)
{
MessageBox.Show("OOM. TotalMemory usage [bytes] =" +
GC.GetTotalMemory(false).ToString());
}
What puzzels me is that the OutOfMemoryException is thrown when
‘GC.GetTotalMemory(false)’ returns between 3 MB and 4 MB, which
is far below the 32MB limit.
The target device has 256 MB of RAM, so how can this be?
I am struggeling with a 'OutOfMemoryException' and would very much like some
help to find out why this is happening.
In the GC class there is a method called ‘GetTotalMemory’.
(http://msdn2.microsoft.com/en-us/library/system.gc.gettotalmemory.aspx) .
According to the documentation this method
“Retrieves the number of bytes currently thought to be allocatedâ€
My understanding is that this method returns the number of bytes that the
process is currently using.
Further, my understanding is that in Windows CE 5.0 each process is limited
to a maximum of 32MB of memory.
My application has approximately 4MB of embedded resources (all of which are
images) that are inclued in the .exe file.
When the application starts I assume that these files are loaded into RAM.
When calling the ‘GetTotalMemory’ just after the main Window or Form has
been displayed, this method returns approximately 4MB, so this seems to
correspond well.
In my program I have added the following piece of code:
catch (OutOfMemoryException OOM)
{
MessageBox.Show("OOM. TotalMemory usage [bytes] =" +
GC.GetTotalMemory(false).ToString());
}
What puzzels me is that the OutOfMemoryException is thrown when
‘GC.GetTotalMemory(false)’ returns between 3 MB and 4 MB, which
is far below the 32MB limit.
The target device has 256 MB of RAM, so how can this be?