<div dir="ltr"><div><div><span style="font-family:courier new,monospace">Hi All,<br><br></span></div><span style="font-family:courier new,monospace">I'm studying how pascal manages strings. I wrote a simple test program:<br>
<br>program stringtest;<br>{$mode objfpc}{$H+}<br>uses Classes, sysutils;<br>function test: PString;<br>var<br> s : string;<br>begin<br> New(Result);<br> Result^ := FloatToStr(Random);<br></span></div><span style="font-family:courier new,monospace">// s := FloatToStr(Random);<br>
</span><div><span style="font-family:courier new,monospace">// Result := @s;<br>end;<br>var<br> i : Integer;<br>begin<br> Randomize;<br> with TList.Create do try<br> for i := 0 to 9 do Add(test);<br> for i := 0 to Count - 1 do begin<br>
WriteLn(PString(Items[i])^);<br> end;<br> finally<br> Free;<br> end;<br>end. <br><br></span></div><div><span style="font-family:courier new,monospace">The program runs fine, but:<br><br></span></div><div><span style="font-family:courier new,monospace">1. I don't know whether I have to MANUALLY free memory for these strings to prevent leak?<br>
</span></div><div><span style="font-family:courier new,monospace">2. Does the IDE provide any facility to analyze memory usage of a program and report if there are any leaks? (There are Tools/Leak View, but I don't know how to get .trc file, or is it what I thought.<br>
<br></span></div><div><span style="font-family:courier new,monospace">Thanks.<br></span></div><div><span style="font-family:courier new,monospace"><br></span></div></div>