defisym/OpenFusionExamples

NeoPic: Memory leak/crash with preload

Opened this issue · 1 comments

Type of issue
Extension bug

Describe the bug
NeoPic's "Set preload path" action causes memory leaks or crashes on application restart

To Reproduce
Steps to reproduce the behavior:

  1. Add a NeoPic (Lib) object.
  2. Add a "Start of Frame: Set preload path" action to a folder with image files
  3. Restart the application after preload completes.
  4. Repeating 3 will make memory usage (see debugger) grow infinitely and can cause crashes.

Additional context
Hi, appreciate your work as always! I'm debugging a number of crashes in my game, one of which I traced back to the NeoPic object. I'm preloading a lot of images in folders, and sometimes the game crashes at the start of the frame. While investigating this, I found out that restarting the application causes NeoPic's preload action to use more memory, and repeatedly doing so can cause a memory leak. I've put together a simple test that crashes within a few seconds on my machine. Sometimes it takes multiple attempts, but it does crash frequently.
crash.zip

I'm not sure if the crash is specifically tied to restarting because I've had crashes from the first attempt as well, but this is the first one I've been able to reproduce more or less consistently.

I found out that restarting the application causes NeoPic's preload action to use more memory, and repeatedly doing so can cause a memory leak

It's a stack memory leak, function that is used to iterate files in a folder recursively didn't close the file handle before return. Thanks for pointing it out!

I've put together a simple test that crashes within a few seconds on my machine. Sometimes it takes multiple attempts, but it does crash frequently.

Cannot reproduce it. Although I also got several crashes on my PC but the position is random, some point to RtlFreeHeap at end but the call stack is external, and some inside mmfs2.dll, which I cannot debug. Maybe you can send this example to Yves, after the 295 release he should be in forum for a few weeks.