Since Java works in a VM is there ever a chance for a memory leak, dangling pointer, etc that would not be fixed when the program quit? I was interviewing last month and the interviewer said there was but I cannot think or find any that fit that case. Maybe he or I misunderstood what the other was saying, this man was extremely smart.
Thanks,
Java Garbage Collector
Page 1 of 16 Replies - 222 Views - Last Post: 29 July 2011 - 07:03 AM
Replies To: Java Garbage Collector
#2
Re: Java Garbage Collector
Posted 29 July 2011 - 06:42 AM
If the program uses too much memory, you can get an OutOfMemoryError. Once an object has no variables pointing to it, then it will be garbage collected. This is most likely what your interviewer was referring to. It's different than when talking about memory management in a more C/C++ context.
#3
Re: Java Garbage Collector
Posted 29 July 2011 - 06:45 AM
Does each Java VM ask for a certain amount of memory before it is run then if it exceeds that amount throws the error? What is too much memory?
#4
Re: Java Garbage Collector
Posted 29 July 2011 - 06:53 AM
You can manually allocate the heap size for the JVM. There are very few instances where you would really need to use more memory. I recall pbl saying once how he had to load thousands of records from a database into memory, then call System.gc() to run the garbage collector. Note that System.gc() attempts to clean up, but does not make any guarantees as to how much can or will be garbage collected. Chances are, if you're going out of memory, there is a more efficient way of doing what you want to do.
#5
Re: Java Garbage Collector
Posted 29 July 2011 - 06:58 AM
I see. Maybe one should be made for you, If macosxnerd101, a man of great intelligence, is ONE OF your DIC's Idol, then put this in your signature to show your support!
This post has been edited by ipushmycar: 29 July 2011 - 06:59 AM
#6
Re: Java Garbage Collector
Posted 29 July 2011 - 07:00 AM
The only way I can see that happening is if you execute native code from Java.
#7
Re: Java Garbage Collector
Posted 29 July 2011 - 07:03 AM
Try generating the number of partitions for 100 using recursion and memorization. You will get an OutOfMemoryError before you reach 70.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote








|