Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > VCL

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 07-26-2016, 04:30 AM
lexd lexd is offline
Senior Member
 
Join Date: Feb 2015
Posts: 268
Question allocating memory to a Object

in IdAntiFreezeBase.pas unit, component TIdAntiFreezeBase is laid out like any normal object.
and then Indy has
HTML Code:
var
  GAntiFreeze: TIdAntiFreezeBase = nil;
Var means the compiler is allocating a TIdAntiFreezeBase pointer and naming it GAntiFreeze. But create is not called so the memory is not allocated for the object's data. Am I correct?

Yet other objects simply access GAntiFreeze as if it's a running object.
as if some one said

HTML Code:
initialization
   GAntiFreeze := TIdAntiFreezeBase.Create(nil);
I would like to know the difference in code (above)
Reply With Quote
  #2  
Old 07-26-2016, 12:46 PM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,329
Default

It's called through InitComponent (GAntiFreeze := Self)

All other code is validated through ShouldUse, which returns False (among other reasons) when GAntiFreeze = nil
Code that uses GAntiFreeze is never executed when ShouldUse is True
Reply With Quote
  #3  
Old 07-26-2016, 10:22 PM
lexd lexd is offline
Senior Member
 
Join Date: Feb 2015
Posts: 268
Default

Indy 9 InitComponent does not exist in any Indy code


Going further back in my code TIdSocketHandle.Readable calls TIdAntiFreezeBase.ShouldUse that defaults to true and the object has no memory allocated to it effectively doing nothing to AntiFreeze a blocked Indy socket. So its not worth the space on the disk drive?
Reply With Quote
Reply

Tags
delphi

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:29 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.