Answer the question
In order to leave comments, you need to log in
Java memory leak. How to track?
There is a timer that should be constantly spinning, possibly a leak because of it (it's embarrassing that I implement it in the constructor, maybe it needs to be done differently), I can't determine the source of the leak, but the code looks something like this:
public class ClockCreater extends JPanel{
public ClockCreater() {
service = Executors.newSingleThreadScheduledExecutor();
service.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
}
}, 0, 1, TimeUnit.SECONDS);
}
}
Answer the question
In order to leave comments, you need to log in
Any profiler. Either with the standard VisualVM, as mentioned above, or through jprofiler, but if you are a severe programmer, then you can also use jmap, jhat, , jstat.jstack and others (also a standard thing)
on the first question:
if the ClockCreater object is created frequently, then not only memory, but also threads may leak (for example, if it is created every time a dialog box is opened). To avoid leaks, after the object is no longer needed, call shutdown on the service.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question