Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous message
koldo is currently offline  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
 
Read Message icon3.gif
Read Message
Read Message
Previous Topic: VectorMap iteration
Next Topic: Add compilable testcases for nontrivial problems!
Goto Forum:
  


Current Time: Fri Sep 05 19:51:27 CEST 2025

Total time taken to generate the page: 0.00708 seconds