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 6096959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:59:16+00:00 2026-05-23T12:59:16+00:00

TBaseClass = class public destructor Destroy; override; end; TFirstClass = class(TBaseClass) FMyProp: string; end;

  • 0
TBaseClass = class
public
  destructor Destroy; override;
end;

TFirstClass = class(TBaseClass)
  FMyProp: string;
end;

TSecondClass = class(TBaseClass)
  FMyFirstClass: TFirstClass;
end;

I need to implement a DESTRUCTOR that can be able to find all (object type) fields from the
same base class and give a Free on it to avoid all those memory leaks.

Why? Because FMyFirstClass be can created or not, that depends on the flow of my app and I can’t garantee when it will be created to Free it, neither do want to fill all destructors with a NIL check kind of code, because i have a lots of fields like that.

I’m trying to use the new RTTI to get all fields based on TBaseClass, but I can’t get the instance of the object-field and I’m out of ideas.

Am I going to the right way? What you suggest to do?

  • 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-23T12:59:17+00:00Added an answer on May 23, 2026 at 12:59 pm

    Calling Free has no effect on a nil instance. It’s deliberately designed that way. Your destructors should call Free on any fields of object types which it logically owns, irrelevant of whether the object has been constructed or not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If have following class public abstract class MyBaseClass : BaseClass { public override string
Given the following class definitions: public class BaseClass { public string SomeProp1 { get;
i have Abstract class Public class Abstract baseClass { public abstract string GetString(); public
I have a class like this: public class BaseClass { public BaseClass(URL url, String
This is the scenario: class BaseClass { public virtual string Prop {get; set;} }
Let's assume I have three classes that are subclasses of a base class: public
I have a situation like this: public abstract class BaseClass { public abstract string
My situation is this: public class InheritedClass : BaseClass { public override void SomeMethod()
Consider the following example: public class BaseClass { public string StringInBaseClass {get;set;} public int
Here is the simple inheritance public class BaseClass { public string Draw() { return

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.