Get the App
SLTechnology News&Howtos  ›  Development  › 

What does a memory leak in Java mean?

Shulou Source: shulou.com Published: 2022-06-01 12:33:53 10月26日 Update

Editor to share with you what a memory leak in Java means, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

What is a memory leak

Memory leak means that you apply to the system to allocate memory for use (new/malloc), and then the system applies for a piece of memory space for this object in the heap memory, but when we have finished using it, there is no delete, resulting in this unused object occupying the memory unit all the time, resulting in that the system will no longer be able to allocate it to the needed program.

The harm of a memory leak is negligible, but the consequence of memory leak accumulation is very serious. No matter how much memory it is, it will be occupied sooner or later, resulting in a memory leak.

Second, the causes of Java memory leakage

1. Static collection classes cause memory leaks:

The use of HashMap, Vector, etc., is most prone to memory leaks. The life cycle of these static variables is the same as that of the application, and all the object Object they refer to cannot be released, because they will always be referenced by Vector and so on.

Static Vector v = new Vector (10); for (int I = 1; I

Tags: Memory objects modules programs systems elements methods listeners listeners situations patterns allocations times articles caches static applications meaning examples content Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Microsoft vpn macOS Docker