Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6838515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:36:23+00:00 2026-05-26T23:36:23+00:00

myarr : array [0 .. 21] of array [0 .. 21] of TColor; above

  • 0
myarr : array [0 .. 21] of array [0 .. 21] of TColor;

above is the declaration , after the use i want to destroy the array of array

for a := 0 to 21 do
  for b := 0 to 21 do
        myarr[a][b].destroy ;
       //myarr[a,b].destroy ;

both the code are giving me error ,

E2018 Record, object or class type required (Delphi)

this is actually implemented inside a class , and i want to do this when the object of class is being destroyed

i have implemented this when a mouse click is executed the previous object(which includes this array) must be destroyed and a new object must be created.Practically when this happens the their must be no any extra memory left , but when i check this in my windows task manager for each click another 200 kb is added ,my app will do this for multiple times.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:36:24+00:00Added an answer on May 26, 2026 at 11:36 pm

    TColor is an integer type, a value type, and is not a class. Accordingly it is does not need to be freed. The definition of TColor is

    TColor = -$7FFFFFFF-1..$7FFFFFFF;
    

    So your array is pretty much equivlent, for the purposes of alloction, to

    myarr: array [0..21] of array [0..21] of Integer;
    

    The elements of such an array do not need to be freed. The array itself will be freed automatically, no matter where you declare it (global, local, class member, record member). It is also a value type.

    The best clue that you don’t need to free TColor is that you never created it in the first place. Allocations and deallocations are always paired.


    As an aside, you should never call Destroy directly. You write Destroy in code only when implemented the overridden destructor for a class, i.e. like this:

    destructor Destroy; override;
    ...
    destructor TMyClass.Destroy;
    begin
      FMyObject.Free;
      inherited;
    end;
    

    When you come to destroy an object you should call Free on it. Do not call Destroy directly. Why not? Well, Free is implemented like this:

    procedure TObject.Free;
    begin
      if Self <> nil then
        Destroy;
    end;
    

    The if statement means that if you have an object reference that is nil, then it is safe to call Free on it without fear of an exception being raised.

    This is important in case an exception is raised in a constructor. When that happens the destructor is called. If the constructor has only partially completed, then some fields will still be nil. Calling Free allows us to write clean destructor code. Without this convenience all our destructors would look like this:

    destructor TMyClass.Destroy;
    begin
      if FMyObject3<>nil then
        FMyObject3.Destroy;
      if FMyObject2<>nil then
        FMyObject2.Destroy;
      if FMyObject1<>nil then
        FMyObject1.Destroy;
      inherited;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have next code: type TRecord1 = record myarr: array [0..31] of single: end;
I want avoid iterating over a nil array. My bad solution: if nil!=myArr myArr.each
I created my model to be a multiple array myArr[10,10]. Then I want that
The following code: import numpy as p myarr=[[0,1],[0,6],[0,1],[0,6],[0,1],[0,6],[0,1],[0,6],[0,1],[0,6],[0,1],[0,6],[0,1],[0,6],[0,1],[0,6],[0,1],[0,6]] copy=p.array(myarr) p.mean(copy)[:,1] Is generating the following
Example code: #include <stdio.h> class compArray { public: unsigned int* myArr; //The array compArray()
I initialized an Array as Double[][] myarr = Enumerable.Repeat(new double[12], 13).ToArray(); Then in a
Suppose I declared an array as following: int myArr = [someSize]; Now I put
I have an array: myarr = []; I'm filling it with some values: myarray['name']
I have written an if...else statement which uses an array myArr and a string
I want to insert the result of a query into a javascript array. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.