You need to sign in to do that
Don't have an account?

Cannot reduce heap size !!
Hello All,
I am programming something which requires a lot of data to be kept in memory for the VF page. And, I am keeping that data in Map.
A button from the page causes this Map to be re-initiated, i.e., to be re-filled.
Now, when I fill the map the first time, it eats up 90% of my heap space. And, to fill it next time, I have to empty it first.., or force it to be garbage collected.
Here is what I have tried :
System.debug('Heap Size 0.1: ' + Limits.getHeapSize() + ' , ' + Limits.getLimitHeapSize()); MainMap = new Map<ID, List<MyClass>>(); System.debug('Heap Size 0.2: ' + Limits.getHeapSize() + ' , ' + Limits.getLimitHeapSize()); MainMap = null; System.debug('Heap Size 0.3: ' + Limits.getHeapSize() + ' , ' + Limits.getLimitHeapSize()); MainMap = new Map<ID, List<MyClass>>(); System.debug('Heap Size 0.4: ' + Limits.getHeapSize() + ' , ' + Limits.getLimitHeapSize());
And, here is the output it produces:
Heap Size 0.1: 937950 , 1000000 Heap Size 0.2: 929766 , 1000000 Heap Size 0.3: 929758 , 1000000 Heap Size 0.4: 929766 , 1000000
As you can see, the heap size is not getting reduced at all, which means I cannot fill the collection again !!
Any pointers or ideas on how I should force this Map to be garbage collected / free up some memory ?
Help would be greatly appreciated !!
Hi there,
I am facing the same issue. Did you find any solution to the problem?
Cheers