Deleting Part of An Array in Java to Free Memory on Heap
Posted
by kate
on Stack Overflow
See other posts from Stack Overflow
or by kate
Published on 2010-04-30T19:29:20Z
Indexed on
2010/04/30
19:37 UTC
Read the original article
Hit count: 183
I am implementing a dynamic programming algorithm for the knapsack problem in Java. I declare the array and then initialize its size to be [number of objects][capacity of knapsack].
When my number of objects or my capacity gets too large, I get a memory error because I run out of space on the heap. My questions is: If I delete rows from my double array as I go along, will Java free the memory as I delete? Or does Java reserve that memory space for the size of the array I originally created? If it's the latter, is there a way to manually free the memory in Java?
Thanks for your Help!
© Stack Overflow or respective owner