Scenario: I have a tree global class (e.g. ZCL_TREE), which has a local class for its nodes (e.g. LCL_NODE).
Each time the insertion method is invoked, a new node instance is created and placed somewhere in the tree (the class LCL_MYNODE has itself references to other nodes, besides the data attribute which happens to be TYPE I).
Now, when invoking the insertion method SEVERAL times (e.g. more than 10000000 times), at some point the server begins to slow down (i'm doing this on sneak preview NW70 system). The process goes to PRIV mode and the whole machine hangs.
I have an almost identical version of this algorithm coded in Java, and, when doing the same over there, as soon as the heap memory is all used up the exception java.lang.OutOfMemoryError occurs, which I can trap. Also, the method call Runtime.getRuntime().freeMemory() returns the remaining available memory.
So my question is: How can I prevent lock ups and hangs by stoping instantiation before the program goes to PRIV mode? I've found exception CX_SHM_OUT_OF_MEMORY but my object is not being created on shared memory (and I don't want to).
Also, i've found class CL_ABAP_MEMORY_UTILITIES which has a method for knowing used memory so far, but not for knowing the remaining memory, which is what I need.
I don't want to mess with BASIS parameters for solving this (e.g. abap/heap_area* or abap/heaplimit), because by increasing memory parameters i'd be just posponing the problem till more memory is used up.
I hope somebody had this need before and can help.
Many thanks
Edited by: Alejandro Bindi on Jul 23, 2008 2:27 PM