BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Memory leak?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi WinAPI
View previous topic :: View next topic  
Author Message
Alien
Guest





PostPosted: Sat Mar 31, 2007 11:37 pm    Post subject: Memory leak? Reply with quote



Using Delphi7

I am using FastMM4 and it shows thet I am getting a memory leak with the code below.
What can I do to fix it with your help that is.

procedure TProject1.GetMyPostedMid; ///
var
P, Q, Temp: PChar;
XFace: array[0..1024] of Char;
begin
P := ReadWrite.GetText; // ReadWrite is a TStringList
Q := StrNew(P);
begin
P := StrPos(Q, 'Message-ID: ');
if P <> nil then
P := P + 12;
Temp := StrPos(P, #13#10);
Temp^ := #0;
StrLCopy(XFace, P, SizeOf(XFace) - 1);
Memo1.Lines.Add(Trim(XFace)); // Adds the Message-ID: <blblbl@watever> to Memo1
end;
end;
--
-A-l-i-e-n-
Back to top
Vertuas
Guest





PostPosted: Mon Apr 16, 2007 2:24 am    Post subject: Re: Memory leak? Reply with quote



"Alien" <aliens (AT) Earth (DOT) humans> wrote in message
news:LdYRmcI0Nf3riUlQ0sVaEdaliens (AT) Earth (DOT) humans...
Quote:
Using Delphi7

I am using FastMM4 and it shows thet I am getting a memory leak with the
code below.
What can I do to fix it with your help that is.

procedure TProject1.GetMyPostedMid; ///
var
P, Q, Temp: PChar;
XFace: array[0..1024] of Char;
begin
P := ReadWrite.GetText; // ReadWrite is a TStringList
Q := StrNew(P);
begin
P := StrPos(Q, 'Message-ID: ');
if P <> nil then
P := P + 12;
Temp := StrPos(P, #13#10);
Temp^ := #0;
StrLCopy(XFace, P, SizeOf(XFace) - 1);
Memo1.Lines.Add(Trim(XFace)); // Adds the Message-ID: <blblbl@watever> to
Memo1
end;
end;
--
-A-l-i-e-n-


Q:=StrNew(p);

this line allocates memory to create a new instance of P

you need to free this memory.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi WinAPI All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.