Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to evaluate breakpoint condition. Reason: Object has been collected

I am getting this error while debugging a Java application in Intellij IDEA.

What is the meaning of this error and how can it be avoided?

This error is very frustrating because it occurs 100% of the time for a specific sequence of code, but stripping code makes it go away. Thus, I am unable to provide a minimal testcase and the application I've got is way too big to share.

I am running under Windows 10, JDK version 1.8.0_161, IntelliJ IDEA 2018.1.

screenshot

like image 813
Gili Avatar asked Apr 11 '18 02:04

Gili


1 Answers

This happens when temporary objects created during the evaluation are collected before the end of the calculation. Usually it may happen when you suspend only one thread and other threads perform GC during this calculation. This will be better handled in 2018.2, sorry for inconvenience.

To avoid this you may add the condition to the code and set the breakpoint inside:

if (<condition>) {
   int a = 5; // set a breakpoint here
}

this is not very convenient but this way you will avoid the issue for sure.

like image 139
Egor Avatar answered Nov 15 '22 07:11

Egor