E
E
EVGENY T.2021-01-20 17:24:43
Java
EVGENY T., 2021-01-20 17:24:43

VisualVM or IDEA?

I am looking for a memory leak in my application using VisualVM. I found objects (MyClass) that get more and more on the heap over time - about 100 per hour.

Next, I want to use the IDEA debugger to figure out what is happening, why the number of objects is growing. And here is a surprise - the collection where the objects live has a size of 15. The number of MyClass objects in memory is 15.

I start VisualVM again, I look at the java process, there the memory explorer shows 100 MyClass objects.

Who is to blame and what to do?

PS MyClass is related to networking and multithreading

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
acwartz, 2021-01-20
@Beshere

Next, I want to use the IDEA debugger to figure out what is happening, why the number of objects is growing. And here is a surprise - the collection where the objects live has a size of 15. The number of MyClass objects in memory is 15.

The garbage collector is on strike, kick it through System.gc()

M
Miron, 2021-01-21
@Miron11

Apparently collections are dispersed in threads ( threads ) that hold something in memory.
If you are using threads directly, you should probably call "return" in the run method so that they signal to the process that they can be safely cleaned up, if they are in some container managed by some default object ( pool ), then here it all depends on the container, there are good ones, but there are all sorts :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question