1

When looking at any given Wt C++ example, there are a lot of new calls but how do these even get deleted? Also, are these even guaranteed to be deleted and if so, when/where?

EDIT: This link pretty much answered how it's probably also done in Wt, although it doesn't directly speak about Wt. Why does the use of 'new' cause memory leaks?

Levi
  • 141
  • 1
  • 9
  • Wt is free software. Look inside its source code! – Basile Starynkevitch Sep 16 '17 at 08:28
  • Please check this post - https://stackoverflow.com/questions/15116077/how-to-clean-up-memory-in-wt – Naseef Chowdhury Sep 16 '17 at 08:46
  • Possible duplicate of [How to clean up memory in WT?](https://stackoverflow.com/questions/15116077/how-to-clean-up-memory-in-wt) – Naseef Chowdhury Sep 16 '17 at 08:46
  • 1
    @NaseefUrRahman Thanks for the link but I actually already read that post. I didn't got a definitive answer to my question concerning new from it though. I'm mostly interested in knowing that it won't cause a memory leak - from the linked thread, it seems to be not the case, at least for return new HelloApplication(env);. – Levi Sep 16 '17 at 09:39

1 Answers1

3

It is a little unsettling to see news without matching deletes..

Wt takes ownership of Wt::Widget pointers that are added to a page or widget hierarchy. They are deleted automatically, as needed.

Very soon Now, a new Wt 4.0 release will clarify this by requiring you to move std::unique_ptrs to these functions, so it is unambiguous that you are transferring ownership. Likewise, functions that remove widgets will return unique_ptrs to the calling code.

Drew Dormann
  • 59,987
  • 13
  • 123
  • 180