Author Topic: Memory leaking  (Read 1857 times)

martol1ni

  • Guest
Memory leaking
« on: April 10, 2012, 01:08:17 am »
Hello.

When creating a NONGAME app, I need to create different pages, obviously. I am using the Containerfunction to do so. That means that TextAdds, ViewAdds are called in functions outside the AppMain (called by AppMain). Is this leaking memory? Take this code snippet par example;

Code: [Select]
int myText = -1;

void showText {
    if (myText == -1)
        myText = TextAdd("Hello Page");
    else TextSetText("Hello Page again");
}

void AppMain {
    int view = ViewAdd("mybg.png",0,0);
    showText();
}

This is never calling myText more than once. Still memoryleaking?

Thanks,
martol1ni

tim

  • Administrator
  • Hero Member
  • *****
  • Posts: 1595
  • Karma: +11/-1
    • View Profile
    • DragonFireSDK
Re: Memory leaking
« Reply #1 on: April 10, 2012, 04:27:40 am »
Hey, martol1ni,

From the code snippet provided, I don't see any issue with this.  Since you're checking the myText variable before calling TextAdd() then there's no issue with leaking memory.

Good question!

Tim
Tim Sommers
DragonFireSDK Team

MetaHaze

  • Guest
Re: Memory leaking
« Reply #2 on: May 27, 2012, 08:47:23 pm »
Following on from the above example:
Is there a way to then destroy the existing text label, so that a different text label could be Added at a later point?

Isn't there a garbage collector anyway?