My program showed trends of memory leak. When the memory usage reached the peak, the GC count was more and the objects were garbage collected.
We found that a class which was the reason for the memory leak trend.
But I would like to check why the class was actually garbage collected and when I explored the class, there was only one transient object in the class.
Transient objects are objects that are not serialized. But does the transient nature have anything to do with garbage collection?
There's no such thing as a transient object. There are transient fields, which are ignored during serialization - but that has no effect on garbage collection.
Basically, I think you need to look elsewhere for your leak (if indeed you even have a leak).
does transient nature have to do anything with garbage collected?
No, nothing.
The transient
keyword indicates it should not be Serialized so if anything it will mean Deserialized objects are smaller than they would otherwise be.
We found that a class which was the reason for the memory leak trend.
You will have a memory leak because you are keeping such a object in a collection when you don't need it. You have to make sure that objects you retain this way are removed when you don't need them.
Just because you are retaining data, doesn't mean you have a leak. You could be needing that data so you need more memory than you expected. In this case you need to increase the maximum memory by setting the -Xmx
or -mx
command lines options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With