• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Memory leaks

 
sunil kumre
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is meany by memory leaks?
 
Les Dsouza
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The garbage collector reclaims memory occupied by an object once it determines that object is no longer accessible.
A memory leak in Java is caused when an object that is no longer needed cannot be reclaimed because another object is still referring to it.
 
sunil kumre
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Les
 
Bhushan Jawle
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Les but coming from a C++ background I think memory leak means a memory which has been allocated and cannot be accessed and hence cannot be reused/freed by system, but in Java that is not the case as garbage collector takes care of such cases,though it is not guaranteed to run programmer does not have to worry about it as in C++ and hence from programmers point of view there is no scope of memory leak in Java. Pls correct me if I am wrong
Regds,
Bhushan
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bhushan,

There is opportunity for memory leaks in Java. Both from a JVM perspective (faulty compilers, fault garbage collector algorithms!) and as a programmer (bad code), if we're not careful. One could argue that bad garbage collectors aren't really 'leaks' as much as they are 'late to collect' or 'non-agressive'. But my point is.. memory leaks can still happen.

I did a little bit of C/C++, and of course in that language, if you are not very careful, you can 'leak' away memory quite easily.

It's much harder in Java, since there is a garbage collector. But it's not infallible.

Here's an old link:
http://www.javaranch.com/ubb/Forum34/HTML/001859.html
 
Bhushan Jawle
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mike.
Regards,
Bhushan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic