Silva wrote:Try it and find out.
i have a big Linked List, this list is dynamic and can grow up very fast. I want to protect this from blowing up java heap space. Is it possbile to use:
Runtime.getRuntime().maxMemory() to get maximum java available memory and then Runtime.getRuntime().totalMemory() to get the actual used memory by my java program and if its at 90% of memory usage use a Semaphore to stop add more entrys.
Is this a good solution ??Impossible to say. I don't know your requirements. What are the consequences for your program if it wants to add something to the list but then is denied?