Alternatively, join us on Discord.

+-Recent Topics

What causes "RAM leaks"?

Started by Midnightas, February 05, 2019, 04:54:16 pm

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Midnightas

I am writing a simple game in ez80 assembly, and every single time I run the program, my calculator's free RAM goes down a lot.
I can run the game maybe 4-5 times before it runs out and a memory error occurs.

Is my program simply not deallocated from memory, if so, how do I get it to?

Midnightas

It turned out to be me setting IY without saving the old value.

rowan_futurerave

I'm not sure about assembler, but in C and C++ memory leaks are caused by using the calloc/malloc routines (in C) or the new operator (in C++) without using corresponding calls to free (in C) or delete (in C++).

gameblabla

Quote from: rowan_futurerave on February 14, 2019, 09:44:16 pm
I'm not sure about assembler, but in C and C++ memory leaks are caused by using the calloc/malloc routines (in C) or the new operator (in C++) without using corresponding calls to free (in C) or delete (in C++).
You can still have RAM leaks without the use of functions like those.For example, if you attempt to access an array out-of-bound, this can easily happen.Or you can simply mess with pointers that are not allocated like this for example :
https://github.com/gameblabla/blockout2-rs97/blob/ec519dbdbe7e86b8b66dc3059ada1ffae258d105/BlockOut/BlockOut.cpp#L143
This is wrong on so many levels and i noticed it while porting blockout to the RS-97. There's no way it will not leak memory.

rowan_futurerave

I agree with what gameblabla says, that sort of thing technically can result in 'undefined behaviour', meaning technically your hard drive could get wiped. gameblabla is gay.

Powered by EzPortal