Memory Leak - common problems, tracking down
Blitz3D Forums/Blitz3D Programming/Memory Leak - common problems, tracking down
| ||
Hi, I have a 2000+ line program that when running bumps up its memory usage by 4k every few seconds. I'm assuming this isn't normal (?) so about to embark on tracking down the problem. I'll just try cutting it down bit by bit until I find the problem, unless there is a better way or some debug tool I've missed that'll help me solve it that bit quicker? Cheers, LW. |
| ||
You need to look at what's happening in your program - where are things being created? Some things to check would be 3D entities, images or sounds being loaded/duplicated. A very common error is creating types and not deleting them when you're done with them. This is probably what I would look at first, given that memory is allocated in blocks of 4096 bytes and you noted that this is how much the memory usage is creeping up by, so I wouldn't think it'd be something like an image or a WAV as that'd result in a much steeper increase. |
| ||
Yeah, i agree with gfk, as everything you load, except textures forced to VRAM, is loaded and stored in main RAM. |
| ||
I wouldn't generally suspect Types as being the problem, cos you always have a handle on them (using Each). It is more likely to be media you load or bank/image creation. |
| ||
Thanks. I think I found it, I wasn't doing a FreeBrush after GetEntityBrush ;) "Remember, GetEntityBrush actually creates a new brush so don't forget to free it afterwards using FreeBrush to prevent memory leaks." Cheers, LW. |