Home » U++ Library support » U++ Core » This is heap leak? (a Ptr use new,no delete,heap leak)
|
|
Re: This is heap leak? [message #61788 is a reply to message #61787] |
Tue, 02 September 2025 11:41  |
 |
koldo
Messages: 3444 Registered: August 2008
|
Senior Veteran |
|
|
Hi Fzx374cn
In addition Ptr goes with Pte.
This is a version of your example. It is not very meaningful but you can see that your pointer does not produce a heap problem, it just returns 0 if the pointed data (Foo data) is out of scope:
struct Foo : Pte<Foo> {
Button but;
};
class Test : public TopWindow {
public:
void Start() {
Foo data;
ptr = &data;
str << "During: " << (void*)~ptr << "\n";
}
Ptr<Foo> ptr;
String str;
};
GUI_APP_MAIN
{
Test t;
t.str << "Before: " << (void*)~t.ptr << "\n";
t.Start();
t.Run();
t.str << "After: " << (void*)~t.ptr;
Exclamation(DeQtfLf(t.str));
}
This shows:
Before: 0x0
During: 0x6fad31f508
After: 0x0
Best regards
Iñaki
|
|
|
Goto Forum:
Current Time: Thu Sep 04 09:20:18 CEST 2025
Total time taken to generate the page: 0.05069 seconds
|