• 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!

GML Visual Memory...

Hey everyone!
Now I'm kinda SICK of memory thing, it's the 4th time I try to make a Tech Demo (Not a full game), only because I reach the same damn point.

Lack of Memory!
I've done everything! Putting my sprites in sprite sheets, reducing at minimum the quantity of objects, nothing leads to a complete and stable game!

Seriously tho, there is another way I could fix this problem ONCE FOR ALL? Is there a way to, I don't know, compress sprites? Most of them doesn't even go over 1 Mb!

Hope you guys could help me as you did before... this is frustrating as hell...
 
J

J_Dev

Guest
When you say memory what do you mean? Does your game eventually crash? If it does crash it may be because you have a memory leak.
 
J

J_Dev

Guest
Invisible textures? Are you using 3D then? Anyway, you may want to double check that you are destroying Data Structures, Surfaces, Particle Systems/Emitters and any other element that can possibly cause memory leaks.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Have you tried simply clearing the compiler cache? Use the "broom" button at the top of the IDE. A stale cache can cause exactly the issues you describe....
 

TheouAegis

Member
Are you using sprite_add()? That's going to cause an increase in the number of texture pages. You could supposedly use vector sprites, but I dunno how well GM actually works with those.

When you say none of your sprites go over 1MB, are you talking about 1MB as displayed in GM's sprite editor or 1MB as a file size? Compressing file sizes won't make a difference because GM will decompress them when loaded and POOF there goes your memory. Compressing sprites within GM, if it had that option, also wouldn't matter toooo much because it would have to decompress before rendering and then POOF there goes more memory. Although, keeping sprites compressed until they're actually needed would be a handy feature.

Edit: @Nocturne I thought it was a dustpan. :p
 
Have you tried simply clearing the compiler cache? Use the "broom" button at the top of the IDE. A stale cache can cause exactly the issues you describe....
What and where is the IDE?

Are you using sprite_add()? That's going to cause an increase in the number of texture pages. You could supposedly use vector sprites, but I dunno how well GM actually works with those.

When you say none of your sprites go over 1MB, are you talking about 1MB as displayed in GM's sprite editor or 1MB as a file size? Compressing file sizes won't make a difference because GM will decompress them when loaded and POOF there goes your memory. Compressing sprites within GM, if it had that option, also wouldn't matter toooo much because it would have to decompress before rendering and then POOF there goes more memory. Although, keeping sprites compressed until they're actually needed would be a handy feature.

Edit: @Nocturne I thought it was a dustpan. :p
I mean no over 1MB in file size. Also, I use drag-n-drop, no scripts. :V
 
D

Danei

Guest
Are you sure your issues are caused by memory and not your draw events or other code?
 
D

dannyjenn

Guest
What and where is the IDE?
"IDE" stands for "[something] development environment". The IDE is GameMaker (the workspace, etc.... where you make the game).
The broom/dustpan/whatever is near the play button. You should see a bug (debug), a triangle (play), a square (stop), and a dustpan (clean).

Could the problem be your computer? Maybe you don't have a good enough graphics card or enough RAM or something. (I can't really give you advice in that regard... I know next to nothing about hardware.)
 

sylvain_l

Member
aren't you just filling your ram/vram by creating instances or sprites every step instead of doing it only once in the create event/or flag check to avoid infinite creation?
 
Are you sure your issues are caused by memory and not your draw events or other code?
100% sure. I've passed the entire Summer with this thing...

"IDE" stands for "[something] development environment". The IDE is GameMaker (the workspace, etc.... where you make the game).
The broom/dustpan/whatever is near the play button. You should see a bug (debug), a triangle (play), a square (stop), and a dustpan (clean).

Could the problem be your computer? Maybe you don't have a good enough graphics card or enough RAM or something. (I can't really give you advice in that regard... I know next to nothing about hardware.)
I'm pretty sure that is not the PC fault, because it has a good graphics card and alot of RAM.

Also, I use GM8, and I can't find the "broom".

aren't you just filling your ram/vram by creating instances or sprites every step instead of doing it only once in the create event/or flag check to avoid infinite creation?
I don't use the step event for creating infinite objects, but I do use the step event for some sprite changes in some objects.
 
N

NeonBits

Guest
I can't find the "broom".
Then:
C/user/yourusername/documents/GameMaker/projects/cache
delete what's in the cache folder.
I also go in
C/user/yourusername/appdata/local
and I delete the gtt folder. Wait for people's advices on that last one, just in case.
 
Then:
C/user/yourusername/documents/GameMaker/projects/cache
delete what's in the cache folder.
I also go in
C/user/yourusername/appdata/local
and I delete the gtt folder. Wait for people's advices on that last one, just in case.
Ok thanks I'll let you guys now.
 

TheouAegis

Member
There is no broom/dustpan in GM8, so none of this will help him. You can't use vector graphics in GM8, so that won't help him either (it was my suggestion, I know).

All you can do in GM8 is use sprite_add() and/or sprite_assign at the start of each room, sprite_delete() at the end of each room, and then cross your fingers. lol I'm not sure if it affects texture pages at all because nobody ever concerned themselves with texture pages in GM8 that I'm aware of. But it is VERY IMPORTANT that you only load the sprites ONCE as needed and delete them when they're not needed. For example, don't have sprite_index=sprite_add(blahblahblah); since that will load a new sprite for each instance. In my GM8 game, I store all the files that are currently loaded in a list. When a room starts, it queries all the spawners (I use spawners, not enemies directly) in the room and loads the sprites they will need. Then when the game transitions to another room, it deletes all the sprites.

But as I said, GM decompresses EVERYTHING, so there's no point in messing with the file sizes.

Oh and depending on how your game is set up, if you are using tiles, you should implement a system where you draw visible tiles and nearby off-screen tiles to a surface at regular intervals and then just draw that surface. You're already having issues with memory, I know, but drawing all the in-view tiles once every 32 steps is a lot, lot faster than drawing all the in-view tiles every single step, which is what GM8 is doing by default. GM8's tile handling is HORRIBLE (but at the same time it's kinda flexible lol).
 
Last edited:
There is no broom/dustpan in GM8, so none of this will help him. You can't use vector graphics in GM8, so that won't help him either (it was my suggestion, I know).

All you can do in GM8 is use sprite_add() and/or sprite_assign at the start of each room, sprite_delete() at the end of each room, and then cross your fingers. lol I'm not sure if it affects texture pages at all because nobody ever concerned themselves with texture pages in GM8 that I'm aware of. But it is VERY IMPORTANT that you only load the sprites ONCE as needed and delete them when they're not needed. For example, don't have sprite_index=sprite_add(blahblahblah); since that will load a new sprite for each instance. In my GM8 game, I store all the files that are currently loaded in a list. When a room starts, it queries all the spawners (I use spawners, not enemies directly) in the room and loads the sprites they will need. Then when the game transitions to another room, it deletes all the sprites.

But as I said, GM decompresses EVERYTHING, so there's no point in messing with the file sizes.

Oh and depending on how your game is set up, if you are using tiles, you should implement a system where you draw visible tiles and nearby off-screen tiles to a surface at regular intervals and then just draw that surface. You're already having issues with memory, I know, but drawing all the in-view tiles once every 32 steps is a lot, lot faster than drawing all the in-view tiles every single step, which is what GM8 is doing by default. GM8's tile handling is HORRIBLE (but at the same time it's kinda flexible lol).
What are vector graphics?
 
D

dannyjenn

Guest
What are vector graphics?
They can't be used in GM8, so don't worry about it.
But if you want to know, they are basically graphics made out of mathematical equations rather than pixels. As such, they can be a lot smaller than bitmap sprites (by "bitmap", I also mean gif and png). So they bring the file size down a little. I'm not sure about RAM though... vector graphics need to be rendered at runtime, and I'm guessing that GameMaker probably renders them just one time and stores them in RAM rather than re-rendering them every frame (which would probably be very slow). If this is the case then they take up the same amount of RAM as regular bitmap sprites.

I personally have never used vector images in GameMaker and I probably won't ever use them unless I need to for some reason. The main advantage to vector images isn't really the file size... the main advantage is that they can be scaled and rotated without losing any quality. If you've ever seen an animation or game made in Flash, those are vector graphics. They have that "smooth" look... and I personally don't like it all that much. (At least not nearly as much as pixel art.)

But as TheouAegis mentioned, GM8 doesn't support vector images. So if you're working with GM8, nothing I just said matters too much.
 
They can't be used in GM8, so don't worry about it.
But if you want to know, they are basically graphics made out of mathematical equations rather than pixels. As such, they can be a lot smaller than bitmap sprites (by "bitmap", I also mean gif and png). So they bring the file size down a little. I'm not sure about RAM though... vector graphics need to be rendered at runtime, and I'm guessing that GameMaker probably renders them just one time and stores them in RAM rather than re-rendering them every frame (which would probably be very slow). If this is the case then they take up the same amount of RAM as regular bitmap sprites.

I personally have never used vector images in GameMaker and I probably won't ever use them unless I need to for some reason. The main advantage to vector images isn't really the file size... the main advantage is that they can be scaled and rotated without losing any quality. If you've ever seen an animation or game made in Flash, those are vector graphics. They have that "smooth" look... and I personally don't like it all that much. (At least not nearly as much as pixel art.)

But as TheouAegis mentioned, GM8 doesn't support vector images. So if you're working with GM8, nothing I just said matters too much.
So, you guys are telling me I can't build a freaking tech demo, because this program goes nuts???
 

TheouAegis

Member
Well, try to rule out the graphics problem. Load your program in GM and click SAVE AS to save it under a different file name. Now close your project and open up that new one. If you have sprite resources, replace them all with a simple 32x32 square. If you have sprite_add() or sprite_replace() codes, change those with references to the simple square sprites. Compile and run. Does it work now? Then your sprites are the issue and you'll need to cut back the sprites somehow.

Out of curiosity, how big are your graphics resources in terms of dimensions? What's the widest graphic's dimensions? What's the tallest graphic's dimensions?
 

rytan451

Member
You can approximate the actual size of the image in RAM and VRAM by finding the area of each image asset (so your sprites and backgrounds), and multiplying by 4. If it's a sprite and it is an animation, multiply by the number of frames in the animation. The number you come up with is the number of bytes the background or sprite takes up.

If your images are too big, the engine won't be able do a thing. Even the most optimised program will not be able to do a thing.

@Bluetail7 Will this work for GM8?
 

Bluetail7

Member
He's not using Studio. There is no Windows tab -- GM8 is strictly for Windows (or Mac if you have the Mac version).
Ah my bad

It could be the dimensions of the graphics, not drawing the background color in the room settings, having the alpha variable messed up, a low powered hardware or outdated directx?
 
Global game settings, Windows tab, Graphics.

Force software vertex processing
There is no option called "Force software vertex processing".
Probably because I'm using GM8.

Well, try to rule out the graphics problem. Load your program in GM and click SAVE AS to save it under a different file name. Now close your project and open up that new one. If you have sprite resources, replace them all with a simple 32x32 square. If you have sprite_add() or sprite_replace() codes, change those with references to the simple square sprites. Compile and run. Does it work now? Then your sprites are the issue and you'll need to cut back the sprites somehow.

Out of curiosity, how big are your graphics resources in terms of dimensions? What's the widest graphic's dimensions? What's the tallest graphic's dimensions?
Technically, most of them are sprite sheets.
The biggest one is 45237x750.
 
dude...
no.
just...
no.


Thats WAY too big! that image alone is like... 150MB! that's not gonna work out for you!
No game, absolutely no game (that actually runs) uses sprites this size!
look into tilemaps, reusing assets, etc.
But... it's just a sprite sheet...
What should I do then? I'm trying everything, and the entire community is pissing off because I'm a nut head! :(

By the way, the file size is 4 MB. So, what the hell???
 

TheouAegis

Member
You can't even get a texture page that size. Just the width alone would cripple any game in any version of gamemaker.
 
D

dannyjenn

Guest
If it's a sprite sheet, why not just split it apart into multiple sprites/frames?
 
just a sprite sheet? do you mean a texture page? or an individual sprite in your game?
show us your image so we can see.


sure, compressed using jpg or whatever.
but GM will have to store raw pixel data on the GPU.
Just one animation.
There you go: https://drive.google.com/open?id=1dYJaBPbkrYl3NgQKXkUBML8TBzUgNjTP

You can't even get a texture page that size. Just the width alone would cripple any game in any version of gamemaker.
You are not wrong at all, but for some reasons, it didn't gave me problems. ¯\_(ツ)_/¯

If it's a sprite sheet, why not just split it apart into multiple sprites/frames?

Some people told me that doing so, will only increase the amount of memory occuped. I don't know how, or why, but that's it.
 

GMWolf

aka fel666
Don't keep a long strip like that. Split it up so you have one image per frame. (There is an option to import sprite sheets).
Also, consider using fewer frames.. that's a fairly large amount. Especially if this isn't your main character.
 
N

NeonBits

Guest
Downloaded one file but scan finds two in one; nevermind.

Is this one single animation? I see only few differences between the frames. When I do animation, I can be lazy and just duplicate the same frame like this. But it's sometimes better to control the animation with a timer and freeze on one frame when necessary.
 
J

Jmation

Guest
I'm pretty sure your images are to big in pixels and the memory is getting eaten up almost instantly. Import or convert sprites to single sprites as others have mentioned. Also pixel size is important not file size as this is what is loaded into memory so have a look at sprite sizes (in pixels) and your texture pages. I have attached an image to help explain how texture pages effects memory.
 

Attachments

N

NeZvers

Guest
1) Separate animations (idle, hit, jump, etc.);
2) Don't use repeated frames in sprite but use image_speed to control animation speed;
3) You don't need higher resolution image than it will appear in game. (750 that's more than half the height of full HD display)
4) If you are using a lot of hi-res sprites and images then learn to use texture page management.
 
Yeah, i didn't notice much animation there either. It looked like a lot of repeating frames.
I always timed animations adding frames. I know it's stupid, but I have no idea how to program with codes...

1) Separate animations (idle, hit, jump, etc.);
2) Don't use repeated frames in sprite but use image_speed to control animation speed;
3) You don't need higher resolution image than it will appear in game. (750 that's more than half the height of full HD display)
4) If you are using a lot of hi-res sprites and images then learn to use texture page management.
But changing the speed, wouldn't make the ENTIRE animation slower?

I'm pretty sure your images are to big in pixels and the memory is getting eaten up almost instantly. Import or convert sprites to single sprites as others have mentioned. Also pixel size is important not file size as this is what is loaded into memory so have a look at sprite sizes (in pixels) and your texture pages. I have attached an image to help explain how texture pages effects memory.
I'd like to put em all in one texture page, but at a certain point I can't load the file because its too big...
 

GMWolf

aka fel666
  1. Your texture is WAY too big! 750 pixels tall? thats over 1/2 of a 1080p monitor! cut it down. Make it the same size as it will appear on screen.
  2. I'm not sure about GM8, but at least since studio, GM will remove repeated frames. So it should be OK. If you repeat every N frames though, you should just slow down the animation. Looking at you animation, you have the same frame repeated very many times. avoid that.
 
  1. Your texture is WAY too big! 750 pixels tall? thats over 1/2 of a 1080p monitor! cut it down. Make it the same size as it will appear on screen.
  2. I'm not sure about GM8, but at least since studio, GM will remove repeated frames. So it should be OK. If you repeat every N frames though, you should just slow down the animation. Looking at you animation, you have the same frame repeated very many times. avoid that.
443 x 375 for a sprite? Is too big?
 

TheouAegis

Member
A computer monitor is typically 1600x900 out of the box now. So a sprite 445 pixels wide by 375 pixels high will take up 1/4 of the screen's width and 1/3 of the screen's height. That's.... nuts. But if you are going for a Samurai Showdown style hyper-zoom, then whatever.

It's 651Kb of memory per frame, so even just 4 frames of animation is over 2Mb of memory occupied at once. Let's say your sprite sheet has 25 frames in it (I'm not going to count them all), that's 16Mb loaded all at once. BUT if you split your sprites up, that's potentially just a bunch of 2Mb sprites that GM could discard as needed. It migut still not fix memory errors in GM8, but it would definitely be work in many other environments. Mostprograms only load the assets that they are going to need into memory, so the smaller the assets, the more assets that can be loaded.

Images should not be more than 1024x1024 in size, possibly 2048x2048 at the max. Those are the safe valyes for texture pages in GMS for compatability reasons.

For custom animations, you would have an array of how many steps each frame will draw for, set an alarm to the value in that array which corresponds to the current image_index, and in the alarm event increase image_index.
 
A computer monitor is typically 1600x900 out of the box now. So a sprite 445 pixels wide by 375 pixels high will take up 1/4 of the screen's width and 1/3 of the screen's height. That's.... nuts. But if you are going for a Samurai Showdown style hyper-zoom, then whatever.

It's 651Kb of memory per frame, so even just 4 frames of animation is over 2Mb of memory occupied at once. Let's say your sprite sheet has 25 frames in it (I'm not going to count them all), that's 16Mb loaded all at once. BUT if you split your sprites up, that's potentially just a bunch of 2Mb sprites that GM could discard as needed. It migut still not fix memory errors in GM8, but it would definitely be work in many other environments. Mostprograms only load the assets that they are going to need into memory, so the smaller the assets, the more assets that can be loaded.

Images should not be more than 1024x1024 in size, possibly 2048x2048 at the max. Those are the safe valyes for texture pages in GMS for compatability reasons.

For custom animations, you would have an array of how many steps each frame will draw for, set an alarm to the value in that array which corresponds to the current image_index, and in the alarm event increase image_index.
Ah come on, if I do something smaller it will be disgusting to look.
Look it by yourself. I need to see the character big, is not a platoformer.
Movimento.png TraximusArma0001.png
 

GMWolf

aka fel666
from one extreem to another.

What size will the image be on screen?
That is the size you want your sprite to be.
 

TheouAegis

Member
That's fine. I said if it's something that you need for your game, then go ahead. As I also said, probably the simplest thing for you to do would be to just break your Sprites up. Do not have repeating frames, use a custom animation code. Do not put multiple animations into the same sprite, give each animation its own sprite. Hell, you might even need or want to give each frame its own sprite. Make it easier for a game maker to allocate memory.
 

kupo15

Member
Ah come on, if I do something smaller it will be disgusting to look.
Look it by yourself. I need to see the character big, is not a platoformer.
View attachment 21368 View attachment 21369
Are you creating a Giant as a main character? Your Sprite sizes on the texture page is too large especially given your inefficient use of duplicating sprites to lengthen the animation. Especially in gm8 you will never make it like this.

You can shrink your sprites down but still scale it up in game to fill the same space on the screen you want which saves memory
 
from one extreem to another.

What size will the image be on screen?
That is the size you want your sprite to be.
I'd like a size which I don't see pixels on. If I shrink it even more, and scale it, it will be obliviously pixelated...

I suggest upgrading to studio and use the .swf files.
Maybe... using .swf sounds a good thing.

That's fine. I said if it's something that you need for your game, then go ahead. As I also said, probably the simplest thing for you to do would be to just break your Sprites up. Do not have repeating frames, use a custom animation code. Do not put multiple animations into the same sprite, give each animation its own sprite. Hell, you might even need or want to give each frame its own sprite. Make it easier for a game maker to allocate memory.
I don't want to sound rude, but because my tech demo is bad programmed, atleast I want it look a bit good.
And reducing even more and more the size of the images will only cause them to look disgusting...

Are you creating a Giant as a main character? Your Sprite sizes on the texture page is too large especially given your inefficient use of duplicating sprites to lengthen the animation. Especially in gm8 you will never make it like this.

You can shrink your sprites down but still scale it up in game to fill the same space on the screen you want which saves memory
Sorry, but if I shrink the sprite down, making it pixelated, how resizing it in GameMaker could be a good choice?
You got what I'm saying...
 

GMWolf

aka fel666
I'd like a size which I don't see pixels on. If I shrink it even more, and scale it, it will be obliviously pixelated...
It will ALWAYS look pixelated, vecabec monitors use pixels!

In fact, using large sprites and scaling down will look bad, because of sampling issues.

The best quality you can achieve is by using sprites that are the same size as they will appear on screen.
(Because the downsampling is done before hand at a higher quality).

And reducing even more and more the size of the images will only cause them to look disgusting...
Again, no. For the reasons stated above.
 

kupo15

Member
Sorry, but if I shrink the sprite down, making it pixelated, how resizing it in GameMaker could be a good choice?
You got what I'm saying...
Of course, that's why you create them at the size you plan are drawing them at like GMwolf said. See, this is all the planning phase of the game, figuring out resolutions and such. Much better to create the sprites smaller at a manageable memory footprint then scale up from there. You didn't answer our questions, is your character actually taking up pretty much half of the screen?
 
Top