• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

System.OutOfMemoryException for No Apparent Reason

Hello, recently GMS has been showing System.OutOfMemoryExceptions for no apparent reason. This is on a completed game that I have not added any huge graphics to or adding anything memory intensive. At first I thought was the async gamepad functions since that's when the System.OutOfMemoryExceptions started. But, after commenting out all of the Async code, the error messages still appear. So, I thought it was than Windows Defender, so I turned off the Real Time protection and the error messages still appear.

I also have the GameMaker Studio 2 runtime in the Windows Defenders exceptions list along with basically any folder GameMaker Studio 2 is located in.

I don't know what's going on, as there's no apparent reason. When I look at the Task Manager for GMS2, it shows it's only using about 43% of RAM. I have 16GB of RAM. I only have 3 tabs open in Microsoft Edge and the texture page size that I have always used is 8192x8192 so I changed it to 4096x4096 then to 2048x2048 with it still showing errors.

These are the error messages GMS2 is showing:

"Error : out of Memory Error!" (With no context why)

"Error : Unable to create a bitmap of size (2048x4096) - out of memory (System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
Error : Unable to create a bitmap of size (4096x2048) - out of memory (System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
Error : Unable to create a bitmap of size (4096x4096) - out of memory (System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
Error : Unable to create a bitmap of size (2048x4096) - out of memory (System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
Error : Unable to create a bitmap of size (4096x2048) - out of memory (System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
Error : Unable to create a bitmap of size (4096x4096) - out of memory (System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
Error : Unable to create a bitmap of size (2048x4096) - out of memory (System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
Error : Failed writing textures out - clear asset cache and try again"

I've cleared the cache several times and stills shows error messages.

Sometimes it shows this error, which I don't believe I've ever had trouble with before:

############################################################################################
ERROR in
action number 1
of Create Event
for object BGM_music_player:

Memory allocation failed: Attempting to allocate 240663491 bytes
at gml_Object_BGM_music_player_Create_0 (line 4) - audio_group_load(BGM_Group);
############################################################################################
gml_Object_BGM_music_player_Create_0 (line 4)
 
Last edited:

Chaser

Member
I had this issue, when I checked my storage status I only had 2gb of ram, gms uses about 1.5gb I think to run, with out all your texture pages loaded. Not saying that’s your problem here, but it’s worth checking your storage anyway. :)
 
I had this issue, when I checked my storage status I only had 2gb of ram, gms uses about 1.5gb I think to run, with out all your texture pages loaded. Not saying that’s your problem here, but it’s worth checking your storage anyway. :)
Storage status on what? The Task Manager shows GMS is only using about 43% and I have 580GB of storage on my SSD.
 

Chaser

Member
How much of the 580gb storage is being used up by Apps, Docs, folders, etc, or if you got 580gb free, then disregard my reply.:)
 

Chaser

Member
OK, the only other thing i think it could be is a memory leak. But maybe someone else with a lot more experience can help you out, I don’t know of anything else.
 
Another type of error message it showed was something about a win32 error. When I checked "use x64 Windows Runtime" the error is gone. That's really odd, since I've been testing games with the 32 bit Runtime for awhile and just recently it was showing the errors.

Does that mean the 32 bit Runtime for games has been discontinued?
 

Chaser

Member
Gms 2 doesn’t support 32 bit anymore I don’t think, don’t quote me on that though, i could be wrong. I would have a look through any logs, updates,announcements or any recommendations to be sure.
 
Actually while using the x64 bit Runtime, it just showed this error:

Win32 function failed: HRESULT: 0x80070000e
Call: GR_D3D_Device-> CreateTexture2D at line 456 in file \TexturesM.cpp
 

Chaser

Member
What is the texture?
I had a some issues when sprite duplicatng and renaming sprites I had already coded somewhere. I duplicated the sprite again, renamed, change the code to point to the new sprite and it worked. Now I’m not saying you should do that, I don’t want to give bad advice, or break your game, but it might help, or might not. Depends on the texture I suppose, or what your doing with it in your code. I’m clutching at straws really.
 
What is the texture?
I had a some issues when sprite duplicating and renaming sprites I had already coded somewhere. I duplicated the sprite again, renamed, change the code to point to the new sprite and it worked. Now I’m not saying you should do that, I don’t want to give bad advice, or break your game, but it might help, or might not. Depends on the texture I suppose, or what your doing with it in your code. I’m clutching at straws really.
The thing is, I don't really know. As I don't remember this happening before. Just yesterday I think it started happening. Any advice on how to check for a possible memory leak?
 

Chaser

Member
Err, check every line of code I’m afraid, I would start with any code that has you drawing textures within a step event/draw event. Alarms being triggered? Loops?
You got to use the debugger and watch the break points t when you error happens.
 
I don't know how much of this I should post publicly but this is more error information being shown:

System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.IO.File.InternalReadAllBytes(String path, Boolean checkHost)
at GMAssetCompiler.GMSound.CompileToAssetCache()
at GMAssetCompiler.WADSaver`1.<>c.(KeyValuePair`2 )
at GMAssetCompiler.Program..(Object )
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
-----------------------------------------------------------------------------
EXCEPTION FILE - C:\Users\**USER**\AppData\Local\Temp\11c389987d9f46ddb959bac91526fd56.yyg.saencryptedreport
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.IO.File.InternalReadAllBytes(String path, Boolean checkHost)
at GMAssetCompiler.GMSound.CompileToAssetCache()
at GMAssetCompiler.WADSaver`1.<>c.(KeyValuePair`2 )
at GMAssetCompiler.Program..(Object )
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
-----------------------------------------------------------------------------
EXCEPTION FILE - C:\Users\**USER**\AppData\Local\Temp\b00b4fa1678a4bdbb046b081cd45ab80.yyg.saencryptedreport
 
My whole PC screen blinked black a couple of times and showed this error:

___________________________________________
############################################################################################
ERROR in
action number 1
of Create Event
for object <undefined>:

Memory allocation failed: Attempting to allocate 340100 bytes
############################################################################################

Then GMS2 crashed and showed an error report window where I uploaded and sent an error report.

This level of errors has never happened before that I can remember.
 
D

Deleted member 13992

Guest
What happens if you try and run some random game or two?

Might help nail down whether the issue if GMS or your PC.
 
What happens if you try and run some random game or two?

Might help nail down whether the issue if GMS or your PC.
After I restarted my PC, when I run the game it just shows a black window where the game should be.

I ran two other projects and they run the way they should.

This is just very odd. Since I haven't done any drastic changes to the game except changes to the gamepad detection. But when I comment that out, the errors still appear.
 
Actually it was showing a black screen because I commented out Audio Groups that needed to load first. But, after restarting my PC, it appears to be working again. But that's what it has been doing. the game will run for a little bit then it shows those errors.
 
Top