Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How does Delphi manage strings in memory?

Status
Not open for further replies.

Eon1

Programmer
Jun 25, 2004
1
ZA
Hi

I was wondering how Delphi allocates and frees memory for string types. I remember hearing somewhere that strings are reference counted, but what would happen if I put a string in something like a record like this:

type
TMyRec = record
X, Y : Integer;
Str : string;
end;
PMyRec = ^TMyRec;

var
MyRec: PMyRec;

begin
New(MyRec);
// Do some stuff with MyRec
Dispose(MyRec);
end;

Would the Str field strictly be a valid and usable string after the call to New and would memory be freed after the call to Dispose? I have the same question for dynamic arrays in Delphi. Could usage like this result in memory leaks?

Eon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top