takashi-ishio / selogger

(Near-)omniscient debugging/tracing/logging tool for Java
Other
35 stars 8 forks source link

A large buffer size likely causes an inifinite loop due to OutOfMemory #23

Closed takashi-ishio closed 2 years ago

takashi-ishio commented 2 years ago

A user told me that a test execution of Apache Commons-Lang with format=nearomni,size=60000,weave=LINE does not complete. I could reproduce the problem. The problem does not occur when the buffer is the default size.

The problem is likely caused by the current implementation allocating a fixed-size buffer for each program location. Each buffer size requires 20 bytes x the value of size= option. When size=60000, 1.2MB per location is required. In case of Commons-Lang, more than 50000 locations exist. I estimated that the required memory is around 60GB. The memory consumption may cause the following behavior.

  1. When a program reached a limit of memory, OutOfMemory exception is thrown.
  2. The program executes exception handlers to throw the exception to callers.
  3. SELogger tries to create a buffer to record the behavior.
  4. The recording may cause an additional OutOfMemory. (Then, the execution goes back to the Step 2)

SELogger needs a special procedure (at least terminating the execution) when reached OutOfMemory.

takashi-ishio commented 2 years ago

The problem is also related to the buffer behavior. By default, buffers keep object references; in other words, GC cannot discard objects created by a target program.

takashi-ishio commented 2 years ago

I have fixed the problem as follows.