Home » U++ Library support » U++ Core » Why this one leaks ?
Why this one leaks ? [message #33766] |
Sun, 11 September 2011 17:07 |
mdelfede
Messages: 1308 Registered: September 2007
|
Ultimate Contributor |
|
|
#include <Core/Core.h>
using namespace Upp;
class Base : public Pte<Base>
{
public:
String BaseData;
Base() { BaseData = "Sample data in Base class"; }
};
CONSOLE_APP_MAIN
{
Ptr<Base> b = new Base;
}
Shouldn't be created element freed on Ptr destruction ?
Here the Upp log :
Heap leaks detected:
--memory-breakpoint__ 1120 : Memory at 0x7f70bdb87210, size 0x20 = 32
+0 0x00007F70BDB87210 53 61 6D 70 6C 65 20 64 61 74 61 20 69 6E 20 42 Sample data in B
+16 0x00007F70BDB87220 61 73 65 20 63 6C 61 73 73 00 65 65 46 72 65 65 ase class.eeFree
--memory-breakpoint__ 1119 : Memory at 0x7f70bdb872b0, size 0x28 = 40
+0 0x00007F70BDB872B0 00 00 00 00 00 00 00 00 19 00 00 00 46 72 65 65 ............Free
+16 0x00007F70BDB872C0 10 72 B8 BD 70 7F 00 00 10 72 B8 BD 70 7F 00 00 .r¸½p...r¸½p..
+32 0x00007F70BDB872D0 19 00 00 00 00 00 1F 0F ........
|
|
|
Re: Why this one leaks ? [message #33767 is a reply to message #33766] |
Sun, 11 September 2011 17:22 |
|
mirek
Messages: 14038 Registered: November 2005
|
Ultimate Member |
|
|
mdelfede wrote on Sun, 11 September 2011 11:07 |
#include <Core/Core.h>
using namespace Upp;
class Base : public Pte<Base>
{
public:
String BaseData;
Base() { BaseData = "Sample data in Base class"; }
};
CONSOLE_APP_MAIN
{
Ptr<Base> b = new Base;
}
Shouldn't be created element freed on Ptr destruction ?
Here the Upp log :
|
You got it wrong way. b is set NULL on Base destructoin, not other way around.
U++ deliberately stays away from "smart pointers" used to manage shared resources.
Mirek
[Updated on: Sun, 11 September 2011 17:22] Report message to a moderator
|
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Sep 20 05:22:30 CEST 2024
Total time taken to generate the page: 0.03730 seconds
|