Originally posted by ajay verma:
how can i come to know about memory is leaking or not?
can you dictate me related one with the help of program?
and what is memory leaking?
There is no simple answer here. In C/C++, a memory leak is defined as memory that has been malloc'ed (new'ed), and lost. All pointers to the memory are gone, which means that it is not possible to reclaim (free / delete) the memory. Yet, the program still thinks that it is in use.
In
Java, the GC takes care of this. So it is not possible to have memory leaks due to setting references to null. However, it is possible to have memory leaks due to "forgotten" references. For example, you write a cache that is used for optimation purposes, but you forget that it uses a static hashmap somewhere. Even if you set all the references to null, this cache located in some static variable will always have a reference.
Now, if this code is part of a jar file, used by the company (and you are no longer with the company), it is highly unlikely that it will be found.
For me, I generally use a profiler to determine memory leaks. The profiler that I use provides a view into the heap -- I know what objects are in the heap, how many of them are there, and their average size. With this, you can determine which objects that are growing in the heap, which shouldn't be... this can be used as likely places to look for memory leaks.
The profiler that I use also provides views into resources, number of open sockets, open files, amount of memory used by which subsystem, etc. With this, you can tell if the system is leaking resources, which is also a sign of a memory leak.
Henry