Main Site Documentation

System.OutOfMemoryException


#1

What is the best way to profile memory pressure? Is there a way to retrieve free space?

EDIT: Debug dump; 24k available, failed to allocate 3096 bytes


GC: 3msec 39696 bytes used, 24684 bytes available
Type 0F (STRING              ):  11016 bytes
Type 11 (CLASS               ):   4440 bytes
Type 12 (VALUETYPE           ):    192 bytes
Type 13 (SZARRAY             ):   2592 bytes
Type 15 (FREEBLOCK           ):  24684 bytes
Type 17 (ASSEMBLY            ):  14676 bytes
Type 18 (WEAKCLASS           ):     48 bytes
Type 19 (REFLECTION          ):     24 bytes
Type 1B (DELEGATE_HEAD       ):    432 bytes
Type 1D (OBJECT_TO_EVENT     ):    336 bytes
Type 1E (BINARY_BLOB_HEAD    ):    156 bytes
Type 1F (THREAD              ):   1536 bytes
Type 20 (SUBTHREAD           ):    192 bytes
Type 21 (STACK_FRAME         ):   2148 bytes
Type 27 (FINALIZER_HEAD      ):    336 bytes
Type 31 (IO_PORT             ):    288 bytes
Type 34 (APPDOMAIN_HEAD      ):     72 bytes
Type 36 (APPDOMAIN_ASSEMBLY  ):   1212 bytes
Failed allocation for 258 blocks, 3096 bytes

    #### Exception System.OutOfMemoryException - CLR_E_OUT_OF_MEMORY (5) ####
    #### Message: 
    #### System.Collections.Queue::Enqueue [IP: 0000] ####
    #### DeLoreanClock.Logger::Log [IP: 00bf] ####
    #### DeLoreanClock.App::UpdateModel [IP: 0049] ####
A first chance exception of type 'System.OutOfMemoryException' occurred in mscorlib.dll
An unhandled exception of type 'System.OutOfMemoryException' occurred in mscorlib.dll


#2

Your memory is fragmented and the system is too busy to clean it up

  1. Plan you code better.
  2. Use “using” statement for force dispose
  3. Add debug.GC(true) to force

#3

Is there a method to obtain the amount of free space?

Its a non-issue really. I was using a queue to store metrics to allow a user to change a memory stick.


#4

It is the same method I pointed out before


#5

I’ve cleaned up and now I can buffer one minute of data.