Tessellation icon indicating copy to clipboard operation
Tessellation copied to clipboard

Memory leak when changing scenes

Open anonymous721 opened this issue 2 years ago • 11 comments

When using Parallax V2.0.6, I am experiencing a memory leak when I change scenes from the KSC. I've tried both entering the VAB and returning to the main menu. The loading screen stays black with the planets not spinning, and VRAM use constantly increases until it overflows into system memory, and keeps climbing indefinitely; I had it exceed 50GB before I killed the process. Alt-F4 frees up the VRAM and most of the system RAM, but not all, and the leftovers are not associated with any process I can see in top, nor in XFCE's task manager, so the only way I've found to clear out that memory is echo 3 > /proc/sys/vm/drop_caches. This does not occur with an older version of the mod (I tested 1.3.1). I have not tested versions in between.

I have mostly tested on game version 1.12.5, but 1.12.2 also exhibits the problem. I currently have other visual mods installed like EVE, but this also occurred with a clean re-install using only this mod and its prerequisites. System is Debian 11, with an AMD RX 6800XT GPU.

anonymous721 avatar Jan 19 '23 01:01 anonymous721

I had a similar issue to this an Arch Linux with only this mod installed. Basically the same black screen and non-spinning planets while RAM kept climbing. Eventually though it either crashed on an out of memory fault, or it loaded into the scene (and memory consumption went back to normal levels). Not sure if it's related to this bug, but since my graphics card only has 3GB of VRAM it might be that it used up all of that before starting on system RAM (although I didn't actually check this). Currently I've "fixed" it by forcing Steam to run KSP via Proton (7.0.5, with a workaround so it runs the KSP binary directly and not the Private Division launcher).

PMunch avatar Jan 23 '23 12:01 PMunch

So you used the Windows version instead of the Linux native one?

anonymous721 avatar Jan 23 '23 15:01 anonymous721

Correct, that's why I wrote "fixed". The issue is gone, and the game runs just fine, but I'd much prefer being able to run it natively.

PMunch avatar Jan 23 '23 16:01 PMunch

Well, it does at least function, and it also does so without the triangular artifacts of #125 , but I'll leave these issues open since it's not a real solution.

anonymous721 avatar Jan 24 '23 04:01 anonymous721

Same problem here with Ubuntu 22.04 and amd proprietary drivers, i can reduce the problem with parallax 2.0,4 and some settings on kopernicus and parallax but what solve most of the problems is set tessellateLighting = false, tessellation still don't work but at least i can play in high

EDIT With Amdgpu opensource drivers with 2.0.6 i don't get artifact on ksc but still memory leak when i go in mapview, 2.0.4 fork fine with tessellation and tessellateLighting =true

NyankoSensei avatar Feb 01 '23 17:02 NyankoSensei

This appears to be caused by forcing KSP (on all platforms) to use OpenGL with the flag -force-opengl, if I let the game run in DXVK there isn't a memory leak (though it's still bad at managing VRAM), which explains why using the Proton version fixed the bug (however it can still be replicated with the opengl launch flag). But the weird part was if I made a new save file, going from the KSC to the Tracking Station didn't cause a memory leak, maybe this was a one-off, I don't know. OpenGL Parallax also seemed to be causing massive spikes in frametime at the KSC, but removing the mod fixes the spikes.

Dupiter-AU avatar Feb 10 '23 09:02 Dupiter-AU

An Interesting Side Note: Parallax on a Real Solar System install and OpenGL on 1.12.3.3173 does not cause a memory leak. Perhaps it's related to the stock Kerbol system?

Dupiter-AU avatar Feb 10 '23 09:02 Dupiter-AU

I fixed this issue. The fix is pretty basic, and Linx has been told about it. He's not going to be able to get it out for a bit though, and as such, he has authorized me to post a dnspy patched build to fix this issue. Enjoy:

Grass.zip

Replace your grass.dll with this.

R-T-B avatar Aug 02 '23 19:08 R-T-B

One step closer to a perfect native KSP modded install! Hooray! Now all that's left is to wait for a fix to the jittery concentric circles in atmospheres of bigger planets with OpenGL

Thanks!

Dupiter-AU avatar Aug 03 '23 00:08 Dupiter-AU

One step closer to a perfect native KSP modded install! Hooray! Now all that's left is to wait for a fix to the jittery concentric circles in atmospheres of bigger planets with OpenGL

Thanks!

That one is harder because it's due to OpenGL running in a whole different runtime mode known as "dual camera" mode. If anyone can save us there, it's blackrack AKA LGHassen on github, but it'd have to be by making the Vulkan renderer work or something. Or applying some kind of dithering to hide it.

One can dream, though... and if anyone can do it I think it's blackrack. Between parallax and Volumetric clouds KSP is a thing of beauty.

R-T-B avatar Aug 03 '23 04:08 R-T-B

I agree, blackrack has done some incredible things for KSP, volumetric clouds must have been a nightmare to implement, and I do believe that if anyone could fix that issue, it'd be them. Just a bit of a shame they don't seem to be very interested in fixing the issue, but I understand with how much other work they have to do :)

Dupiter-AU avatar Aug 04 '23 02:08 Dupiter-AU