RaiaN/RuntimeImageLoader

Memory leak

Closed this issue · 14 comments

Hello I create a system of replicated graffity with the help of your plugin to create a cache system for each graff, but I found a memoryleak in your plugin, because when I load many png then close the editor the vram is not flush so you can simply code this:

image

To reproduce the memory leak, so you start the game then you stop you restart.. And you can see the vram increasing without flushing. Let me know if you need more information or if I simply need to do something to handle this myself thank in advance !

RaiaN commented

Hi @amnedgeToulouse! Thanks for feedback and sorry for the memory leak :( I've previously tested the plugin with GC collection enabled...

Let me reproduce this error and fix it!

RaiaN commented

Hey @amnedgeToulouse. Not sure how you got the memory leak but I don't see the same when looking at Task Manager vram.
Can you please share your setup in more details?

I also fixed some minor issues. Please try new release and let me know how it works.

P.S. Unreal has GC that is activated every N seconds so that is why you maybe experiencing what you posted above.

Hey @RaiaN Hum I got basic unreal parameter I don't modify GC parameter maybe I have something to do there ? I create a video that show you some information, and I let the editor open for many times and the memory doesn't go down, maybe try with a big image that you load like me, can you show me your code to test the bug ?

The video:
https://www.youtube.com/watch?v=G4yXumI40nk

RaiaN commented

@amnedgeToulouse Thanks! Let me see what is going on...

RaiaN commented

I reproed the error. I though I have to close the Editor but it seems that GPU vram does not go down after EndPlay event. Looking into the memory leak now

RaiaN commented

@amnedgeToulouse Thanks for report! I've fixed the memory leak. Feel free to grab new release:

https://github.com/RaiaN/ue4_runtimeimageloader/releases/tag/1.1.4

Perfect ! Can you provide me a version of the plugin with Binaries and Intermediate because I don't have a compiled version of the engine so I can't compile your plugin :/

I'll test it after that and tell you if it works well :)

RaiaN commented

@amnedgeToulouse Just updated the latest release.

Hey @RaiaN I download the update from epic game store but I still got the same issue I reproduce it like it in the video. Maybe I have to wait a specific amount of time before the memory flush ??

image
Exactly is 61.099998s, you can decrease it if you want. But it causes a drop FPS every time it is active, so don't set it 1 or 2 seconds. Or you can call it from BP by "Collect Garbage" when you clear the widget (Make sure that widget doesn't have any reference from others, it means not save by any Variable in any Blueprint)

RaiaN commented

@amnedgeToulouse Update was released on Epic Games Marketplace late yesterday! Now you should not see any memory leaks

RaiaN commented

@FlamingFuryVN
@amnedgeToulouse was talking about GPU vRAM memory leak. Previously I didn't cleanup all texture references properly so even if GC did its job the texture would still be in GPU memory.

@FlamingFuryVN @amnedgeToulouse was talking about GPU vRAM memory leak. Previously I didn't cleanup all texture references properly so even if GC did its job the texture would still be in GPU memory.

Yes, I know. I already test them (The newest version) every time I use GC without saving history on my project. The VRAM goes down as well. But if not using GC, the VRAM is still there. Keep increasing when loading new. Auto GC is only active after 60s or EndPlay

RaiaN commented

Ah, gotcha. Yeah, that is consequence of Unreal GC system. Texture object is not destroyed until GC does so (or until there is an explicit request to destroy such texture object)