Facepunch / garrysmod-issues

Garry's Mod issue tracker
136 stars 56 forks source link

Direct3D Memory Leaks #2824

Open Jake3231 opened 7 years ago

Jake3231 commented 7 years ago

Upon investigating memory leaks in Gmod on my Mac, I found a pretty big leak that appears to involve Direct3D. I used Instruments to watch the hl2_osx process for memory leaks, and it found one that repeated over and over again — IDirect3DTexture9::GetSurfaceLevel(unsigned int, IDireect3DSurface9**). To be more specific, it says that the responsible library is libtogl.dylib, and IDirect3DTexture9::GetSurfaceLevel(unsigned int, IDireect3DSurface9**) is the responsible frame, according to Instruments. It would be great to have this fixed, as the OS X version of Garry's Mod is only 32-Bit, and needs to be efficient in its memory use.

Bo98 commented 7 years ago

There's been some memory leaks in Valve's ToGL wrapper (Valve's Direct3D to OpenGL layer) over the years so it's possible that this is one of them. I think @willox intends to update ToGL at some point.

Jake3231 commented 7 years ago

Okay. That would be great to do. If I'm correct, isn't ToGl open source, and it's possible to manually tweak it? If so, maybe that would be worth looking into also.

Bo98 commented 7 years ago

ToGL is open source but they haven't updated their GitHub repo since March 2014. I have no idea if Facepunch can get more up-to-date code through TF2 or something.

Jake3231 commented 7 years ago

Okay... I wish they were still updating it! I think that it would be great to check TF2, or maybe even consider another wrapper. That would be a massive change, I assume, but I think that ToGl has generally had lots of problems.