While programs in the Java language are theoretically immune from memory leaks, there are situations in which objects are not garbage collected even though they are no longer part of the program’s logical state. This article explores a common cause of unintentional object retention and shows how to plug the leak with weak references.
a common memory leak is forgetting objects in a vector. the gc works fine… but since you are just adding to it it builds up. it seems trivial but when you have large multi-layered apps this is not so easy to spot.
We were told that thanks to a GC we did not have to manage memory and did not have to worry about memory leaks. That seemed fine even if Java based applications were slower than in C++. Now if we still have to manage memory anyway, I do not see the point of using Java. Or .Net either, which with 2.0 is getting as complex if not more than C++. For performance and simplicity and flexibility, C++ is best.
You are so clueless about Java MM. The problem arises because developers and their respective programs mantain references to objects and therefore said objects can not be GC’d if they are strongly referenced. Once an object is no longer referenced, the GC can reclaim the memory. So you are NOT managing memory, you are managing the lifecycle of your objects. So memory leaks mentioned can easily be avoided so long as you manage your references, but if you create an object and reference it in multiple places throughout your program, the GC will not reclaim the memory used by that object so long as one of the references is still valid.
it’s only a minor issue hardly relevant to most java programs!
oh and i wouldn’t say c++ is better for similicity but maybe for performance by a little.