Ebay Interview Question
Software DevelopersCountry: United States
False. JVM garbage collector will collect circular references, unless they're reachable from the top.
Here's an example of a memory leak. Suppose you have a static field that holds an observer, whose purpose is to notify anyone interested whenever one of the objects it observes has changed. Since it's a static field, anything it references is reachable from the top and will never be collected. Suppose you add an object to the observer, so that anyone interested will be notified while you're working with it. Let's say that when you're done with it, you forget to remove it from the observer. It will never be modified again or touched by anyone else, but it is still reachable from the top and won't be collected. That's a JVM memory leak.
False. JVM garbage collector will collect circular references, unless they're reachable from the top.
Here's an example of a memory leak. Suppose you have a static field that holds an observer, whose purpose is to notify anyone interested whenever one of the objects it observes has changed. Since it's a static field, anything it references is reachable from the top and will never be collected. Suppose you add an object to the observer, so that anyone interested will be notified while you're working with it. When you're done with it and you're sure it won't be modified again, you should remove it from the observer. If you don't, it will forever be reachable from the top and will never be collected. That's a memory leak.
False. JVM garbage collector will collect circular references, unless they're reachable from the top.
Here's an example of a memory leak. Suppose you have a static field that holds an observer, whose purpose is to notify anyone interested whenever one of the objects it observes has changed. Since it's a static field, anything it references is reachable from the top and will never be collected. Suppose you add an object to the observer, so that anyone interested will be notified while you're working with it. When you're done with it and you're sure it won't be modified again, you should remove it from the observer. If you don't, it will forever be reachable from the top and will never be collected. That's a memory leak.
Have two objects refer to each other, and nothing else referring to either of them.
- RecruitingForSandvineCanada June 07, 2015That's a leak.
Ping me for opportunities.