We're on Discord! Please join our server now if you don't want to miss anything! (More info) | Join the UCC4 contest! (More info)

* WalrusIRC (More rooms available on our Discord server)

Author Topic: What causes "RAM leaks"?  (Read 1031 times)

0 Members and 1 Guest are viewing this topic.

Offline Midnightas

  • New User
  • Join Date: Feb 2018
  • Location:
  • Posts: 7
  • Post Rating Ratio: +0/-0
  • Making hello worlds since 10.
    • @UCt26YFLiAK1T3b3o-1IZXKw
    • @midnightas
What causes "RAM leaks"?
« on: February 05, 2019, 04:54:16 pm »
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?



Offline Midnightas

  • New User
  • Join Date: Feb 2018
  • Location:
  • Posts: 7
  • Post Rating Ratio: +0/-0
  • Making hello worlds since 10.
    • @UCt26YFLiAK1T3b3o-1IZXKw
    • @midnightas
Re: What causes "RAM leaks"?
« Reply #1 on: February 07, 2019, 06:07:42 am »
It turned out to be me setting IY without saving the old value.

Offline rowan_futurerave

  • Full User
  • Disabled shoutbox mode
  • Restricted (shoutbox)
  • Join Date: Aug 2018
  • Location:
  • Posts: 45
  • Post Rating Ratio: +0/-0
    • rowanmedhurst
    • Futurerave
  • Gender: Male
Re: What causes "RAM leaks"?
« Reply #2 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++).
  • Calculators owned: TI-84 Plus CE-T, CASIO fx-CG50

Offline gameblabla

  • Super User
  • Join Date: May 2015
  • Location:
  • Posts: 826
  • Post Rating Ratio: +15/-7
  • TI-nspire porter
Re: What causes "RAM leaks"?
« Reply #3 on: February 20, 2019, 08:52:04 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.
  • Calculators owned: TI Nspire CX, TI-89

Offline rowan_futurerave

  • Full User
  • Disabled shoutbox mode
  • Restricted (shoutbox)
  • Join Date: Aug 2018
  • Location:
  • Posts: 45
  • Post Rating Ratio: +0/-0
    • rowanmedhurst
    • Futurerave
  • Gender: Male
Re: What causes "RAM leaks"?
« Reply #4 on: February 23, 2019, 07:05:47 am »
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.
  • Calculators owned: TI-84 Plus CE-T, CASIO fx-CG50

 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games