Author Topic: Preventing Memory Leaks  (Read 2087 times)

EricB

  • Jr. Member
  • **
  • Posts: 61
  • Karma: +1/-0
    • View Profile
Preventing Memory Leaks
« on: February 17, 2013, 03:51:39 pm »
I have some questions about preventing memory leaks. Lets take for example the Box2D sample that comes with DragonfireSDK. Would you need to put anything into appexit() to clean up after this sample? Or is everything ok because the functions Createbounds() and Creatshapes() are called from appmain()? What about the variable pointers b2world *World, b2body *bodies[], b2body *bounds[]?
Thanks for any info / advise.

EricB

glina126

  • Guest
Re: Preventing Memory Leaks
« Reply #1 on: February 17, 2013, 05:51:55 pm »
you can destroy the bodies, but honestly I dont see a point in doing that. you game is being turned off anyway, meaning al the pointers and etc get erased from the memory. The way I see it is if you dont need to save anything. You dont need to do anything on App Exit.

nednones

  • Guest
Re: Preventing Memory Leaks
« Reply #2 on: February 20, 2013, 08:42:29 am »
glina126 is right, however if you need to destory an object as it is no longer needed, say an actor in your game then delete physically as the creation of objects will start to cause memory leaks.

EricB

  • Jr. Member
  • **
  • Posts: 61
  • Karma: +1/-0
    • View Profile
Re: Preventing Memory Leaks
« Reply #3 on: February 20, 2013, 10:39:57 am »
Thanks guys, looks like I don't have to worry about it in my app.

glina126

  • Guest
Re: Preventing Memory Leaks
« Reply #4 on: February 20, 2013, 10:20:44 pm »
Thanks guys, looks like I don't have to worry about it in my app.
The only thing I would recomend is to hide the iAd if you have ads before your app goes into suspend mode or app exit. This could cause some nice bugs in the iOS if someone calls you or when the apps are switching hahaha I learned the hard way  :o

And never create any views uncontrollably. In other words create them at a start of the app in appMain, never again later
« Last Edit: February 20, 2013, 10:22:49 pm by glina126 »