Hi guys
I'm currently facing a problem with my game that displays this message of error

I discussed it a bit with @Crimson Wizard and this seems to be due to a RAM overflow, the current limit of the engine is 3GB.
My game is not really adapted to the AGS engine,it's not really a point and click but more of a RPG. This entails a very greedy use of graphics :
-My maps are 2800*5000px ,oO
-the enemies get created cutting a big spritesheet into dynamic sprites that create 5 views of 8 directions and 8-16 sprites per loop(on average that's 480 sprites per enemy)
-The player's pieces of armor get created similarly creating views for each one, this time:7 views of 8 directions and 816 sprites per loop (670 sprites per piece of armor).
At first I planned to create all the views at startup and then just use them but this definitely asks too much memory. So I tried to divide the needed memory by just loading what's necessary and then deleting the sprites.
For example :
-At game start, the game loads the first map and the 5 first pieces of armor. It also loads the NPC on that map(by creating the necessary views through dynamic sprites).
-When the player changes room, the pieces of armor are kept because the player still wears them, but all the dynamic sprites for NPC get erased to create the new ones : the ennemies from this zone.
-If I get back to the first one, those same dynamic sprites are erased again and replaces by the NPC's.
-and so on...it's a bit longer to load maps because the game creates and recreates over again each time but this saves RAM.
The problem is, even with this method the game still crashes, it actually seems that the 3GB limit is reached very quickly.
According to my calculations, each enemy should use around 125mB, and armor is 175mB. Which means that if I carry 6 pieces of armor (helmet,shoulder,weapon1 and 2, torso and trousers), I already reach 1/3 of my allowed space. Each map loads around 8 different enemies so that's 1/3 more. My map takes around 120mB so that doesn't leave much room, but still it should work.
Do you know how much RAM loaded arrays take(because I use a lot of those for spells, capacities,ennemy stats etc.), and do you think this should also be reduced to a strict minimum? Same for sprites, I use 256*256 because it's more convenient but I guess I could crop the sprites to the minimum necessary, should I ? Or do you have other suggestions to keep my RAM alive ?
Thanks a lot
I'm currently facing a problem with my game that displays this message of error

I discussed it a bit with @Crimson Wizard and this seems to be due to a RAM overflow, the current limit of the engine is 3GB.
My game is not really adapted to the AGS engine,it's not really a point and click but more of a RPG. This entails a very greedy use of graphics :
-My maps are 2800*5000px ,oO
-the enemies get created cutting a big spritesheet into dynamic sprites that create 5 views of 8 directions and 8-16 sprites per loop(on average that's 480 sprites per enemy)
-The player's pieces of armor get created similarly creating views for each one, this time:7 views of 8 directions and 816 sprites per loop (670 sprites per piece of armor).
At first I planned to create all the views at startup and then just use them but this definitely asks too much memory. So I tried to divide the needed memory by just loading what's necessary and then deleting the sprites.
For example :
-At game start, the game loads the first map and the 5 first pieces of armor. It also loads the NPC on that map(by creating the necessary views through dynamic sprites).
-When the player changes room, the pieces of armor are kept because the player still wears them, but all the dynamic sprites for NPC get erased to create the new ones : the ennemies from this zone.
-If I get back to the first one, those same dynamic sprites are erased again and replaces by the NPC's.
-and so on...it's a bit longer to load maps because the game creates and recreates over again each time but this saves RAM.
The problem is, even with this method the game still crashes, it actually seems that the 3GB limit is reached very quickly.
According to my calculations, each enemy should use around 125mB, and armor is 175mB. Which means that if I carry 6 pieces of armor (helmet,shoulder,weapon1 and 2, torso and trousers), I already reach 1/3 of my allowed space. Each map loads around 8 different enemies so that's 1/3 more. My map takes around 120mB so that doesn't leave much room, but still it should work.
Do you know how much RAM loaded arrays take(because I use a lot of those for spells, capacities,ennemy stats etc.), and do you think this should also be reduced to a strict minimum? Same for sprites, I use 256*256 because it's more convenient but I guess I could crop the sprites to the minimum necessary, should I ? Or do you have other suggestions to keep my RAM alive ?
Thanks a lot
