Steamworks.NET icon indicating copy to clipboard operation
Steamworks.NET copied to clipboard

Out of Memory Issues

Open sloankelly opened this issue 12 years ago • 5 comments

Running into out of memory errors in the editor and builds with Steamworks.net. This happens a lot when requesting leaderboard stats, and when quitting the game:

Could not allocate memory: System out of memory! Trying to allocate 4197694132B with 4 alignment. Memory label UTF16String, Allocation Happend at: line 133 in ....TextUtil.cpp

And on exit:

Fatal error! CheckDisalowAllocation. Allocating memory when it is not allowed to allocate memory.

Tested on Windows 7/8 and Unity 4.3.7p3 with Steamworks.net "Stable, 5.0.0 unitypackage". Using Steam SDK 1.31. Build settings in Unity are set to x86_64

sloankelly avatar Nov 25 '14 19:11 sloankelly

That's interesting, I've never seen this happen before, do you have a stacktrace for either of those?

rlabrecque avatar Nov 25 '14 21:11 rlabrecque

I'll try and get one, but it's usually just a dialog that appears, and it's happening less frequently when I have it as x86_64, I can go back to just x86 and should be able to repro it quickly.

sloankelly avatar Nov 26 '14 01:11 sloankelly

Can't get a stack trace, I'm afraid, but I did get this screen:

Fatal Error

When I called:

    SteamAPICall_t handle = SteamUserStats.FindLeaderboard(leaderboard);
    LeaderboardFindResult.Set(handle);

I'm also getting that error when I stop the game in the Unity editor.

sloankelly avatar Nov 26 '14 20:11 sloankelly

Found the problem; buffer overrun on my part. When I fetch back the data for each leader board, I allocate one slot, but try and read more. I think the code, in the Steam API, doesn't do the bounds check and that's why I was getting memory problems. These manifested themselves everywhere not just in the Steamworks code.

tl;dr You're library is awesome, I didn't use it right.

sloankelly avatar Jan 05 '15 18:01 sloankelly

Ah awesome, yeah that would explain it! Extreme care has to be taken when calling into native code, Steamworks.NET currently doesn't do it automatically as to maintain 1:1 compatibility with Valve's C++ Steamworks.

I'm glad that you got it working though!

rlabrecque avatar Jan 08 '15 19:01 rlabrecque