Linked by Thom Holwerda on Tue 22nd Nov 2005 15:32 UTC, submitted by anonymous
Java 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.
Order by: Score:
caching
by CaptainPinko on Wed 23rd Nov 2005 04:24 UTC
CaptainPinko
Member since:
2005-07-21

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.

Reply Score: 1

WHAT ?
by Anonymous on Wed 23rd Nov 2005 13:38 UTC
Anonymous
Member since:
---

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.

Reply Score: 0

RE: WHAT ?
by Anonymous on Wed 23rd Nov 2005 14:31 UTC in reply to "WHAT ?"
Anonymous Member since:
---

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.

Reply Score: 0

Re: WHAT ?
by Anonymous on Wed 23rd Nov 2005 13:50 UTC
Anonymous
Member since:
---

it's only a minor issue hardly relevant to most java programs!

Reply Score: 0

Re: WHAT ?
by Anonymous on Wed 23rd Nov 2005 13:51 UTC
Anonymous
Member since:
---

oh and i wouldn't say c++ is better for similicity but maybe for performance by a little.

Reply Score: 0