Hi, kindly let me know if memory leak happens if we store objects in a HashMap.Also let me know other possibilities of memory leaks.
posted 11 years ago
It really depends on you, as a developer. Nothing to do with whether using a HashMap will cause memory leaks or not. For example, if you're creating objects now and then, and storing them into a HashMap, and yet not using it at all, clearly, we'll see an increase in memory usage and eventually out of memory may occur. You don't have to use a HashMap to see this, a Vector or ArrayList would work too.
Loitering objects and creating many short-lived objects are two main culprits of memory leaks. Do a Google search & you'd find more information on them.