Author Topic: memLeak when priming grenades?  (Read 4171 times)

Offline kevL

  • Colonel
  • ****
  • Posts: 482
  • pitchforks and torches
    • View Profile
memLeak when priming grenades?
« on: September 13, 2013, 11:30:48 pm »
I'm just learning c++ (don't laugh unless you want to)

i have a lot of experience with NwScript (don't underestimate it..)


So, in PrimeGrenadeState.cpp, I come across the destructor and notice it doesn't explicitly delete _title, _window, _bg, etc. Yet in other destructors, eg. Inventory.cpp, I notice that these 'new' subobjects are explicitly deleted. So i'm wondering:

is that a memory leak?


[ edit ] I'm guessing, not, because in BattlescapeState.cpp i see a bunch of 'news' that are also not explicitly deleted (yet some are..) in the destructor. Perhaps some of those subobjects are automatically deleted when the object itself is deleted...
« Last Edit: September 14, 2013, 12:19:25 am by kevL »

Offline SupSuper

  • Lazy Developer
  • Administrator
  • Commander
  • *****
  • Posts: 2162
    • View Profile
Re: memLeak when priming grenades?
« Reply #1 on: September 14, 2013, 02:06:46 am »
Yeah this tends to throw people off as Surfaces added to a State through add() are automatically handled by the base State destructor (just a convenient shortcut), but other elements still need to be manually destroyed.
« Last Edit: September 14, 2013, 05:50:21 pm by SupSuper »

Offline kevL

  • Colonel
  • ****
  • Posts: 482
  • pitchforks and torches
    • View Profile
Re: memLeak when priming grenades?
« Reply #2 on: September 14, 2013, 02:39:12 am »
ok, thanks Sup.

will keep trudgin on then,