Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need to free these objects?

Tags:

delphi

I'm using Delphi 1 16-bit to learn Pascal (don't laugh, it works fine, plus I can't afford a more recent version). I'm using a TList to hold object references for a simple address book. Each object is added to the TList like so:

DataList.Add(TAddrBookData.Create('Bob', '1 Mill St'));

Do I need to free the TAddrBookData objects myself? Or are they freed when TList.Free is run?

like image 270
FrankCM Avatar asked Jul 07 '10 12:07

FrankCM


People also ask

What are free falling objects?

An object that is moving only because of the action of gravity is said to be free falling and its motion is described by Newton's second law of motion.

What is the formula for falling objects?

vf = g * t where g is the acceleration of gravity. The value for g on Earth is 9.8 m/s/s. The above equation can be used to calculate the velocity of the object after any given amount of time when dropped from rest.

What does the law of inertia say?

Newton's First Law: Inertia Newton's first law states that every object will remain at rest or in uniform motion in a straight line unless compelled to change its state by the action of an external force.

What is the only force acting on free falling objects?

As learned in an earlier unit, free fall is a special type of motion in which the only force acting upon an object is gravity.


1 Answers

You need to free them yourself. Later versions come with a TObjectList, which is like a TList except it will only accept objects and it has the option to take ownership and free them for you automatically when the list is freed. But I don't believe TObjectList existed in Delphi 1, so you'll have to take care of it manually.

like image 82
Mason Wheeler Avatar answered Oct 19 '22 05:10

Mason Wheeler