Getting Out of memory exception even when the memory is not full

  • Thread starter Thread starter Aravind
  • Start date Start date
A

Aravind

Hi,
I am ruuning to out of memory exception , My system has RAM of 4 GB
and virtual memory paging size set to 4GB .When I check the memory
occupied by the process during the exception , it is less ( around 500
MB and peak Memory usage 800MB , even the total memory of the system
is not high . what are passing use cases where the system leads to out
of memory exception ?
I am using two process for the program and the out of memory occuring
in the second process.

Thanks in Advance

Regards
Aravind
 
Aravind said:
Hi,
I am ruuning to out of memory exception , My system has RAM of 4 GB
and virtual memory paging size set to 4GB .When I check the memory
occupied by the process during the exception , it is less ( around 500
MB and peak Memory usage 800MB , even the total memory of the system
is not high . what are passing use cases where the system leads to out
of memory exception ?
I am using two process for the program and the out of memory occuring
in the second process.

There are a few things I've run into that will cause this.

1) A recursive loop that allocates memory.
2) An attempt to allocate memory that is WAY outside of the total
amount available (such as a stray long value passed to the allocator).
3) An attempt to allocate a negative number.

Matt
 
Aravind said:
Hi,
I am ruuning to out of memory exception , My system has RAM of 4 GB
and virtual memory paging size set to 4GB .When I check the memory
occupied by the process during the exception , it is less ( around 500
MB and peak Memory usage 800MB , even the total memory of the system
is not high . what are passing use cases where the system leads to out
of memory exception ?
I am using two process for the program and the out of memory occuring
in the second process.

Thanks in Advance

Regards
Aravind

How large are the objects you are creating?
You can get OOM exceptions when there is not enough free memory in one
'contiguous' block to fulfill the request as a result of memory
fragmentation.
Say you have 900 MB total Virtual address space available , with the largest
block being 200MB , when your application needs 201MB for a string array it
will fail with an OOM exception as there is no block large enough to hold
the array. Pay special attention to ArrayLists, they grow by a factor 2 when
they get full.

Willy.
 
Back
Top