I have a type definition
Type Person
dim as string PersonName
...
Declare Destructor
End Type
The question is: What is the proper way to not lose track of the memory used for the storage of the String variable in the Destructor.
I assume the default Destructor reclaims the memory used by the string variable, but since I have my own Destructor, the default Destructor does not get executed right?
Proper way to stop memory leak
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
I'm pretty sure FB handles the string deallocation for you, even if you have a non-default destructor, just like it handles string allocation in a non-standard constructor... You don't have to do memset(@this.my_string, 0, 12), for example.
Sorry, I have to work on my (64-bit) environment to get FB to a point where I can compile stuff again. ;)
Sorry, I have to work on my (64-bit) environment to get FB to a point where I can compile stuff again. ;)
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
Actually, yeah, I think cha0s is right. It probably destroys all the UDT's elements automatically, and just uses the destructor to do cleanup work beforehand, such as destroying objects you created manually earlier.
So, it probably works like this:
This would make more sense actually: if there weren't default constructors/destructors, you'd have to placement-new and "placement-destroy" all the object elements yourself, which is probably a serious violation of RIAA principles.
EDIT: oops, RAII, not RIAA.
So, it probably works like this:
Code: Select all
default constructor
manual constructor
...
manual destructor
default destructor
EDIT: oops, RAII, not RIAA.