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

  • Home
  • SEARCH
  • 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 914461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:43:18+00:00 2026-05-15T17:43:18+00:00

I have been running into errors where objects are somehow freed but we end

  • 0

I have been running into errors where objects are somehow freed but we end up calling FreeMem on them. Of course this causes an error since the memory has already been freed and throws an error.

I know that a try-catch block would probably fix it but that’s a lot of try-catch blocks. With the regular object.free the way to avoid this is FreeAndNil(object) but I can’t find the equivalent for FreeMem. Something which tests whether it’s allocated or not before freeing.

What’s the best solution here in ease of reading, maintainability, and stability.

  • 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-15T17:43:19+00:00Added an answer on May 15, 2026 at 5:43 pm

    The equivalent to FreeAndNil would just be

    FreeMem(p);
    p := nil;
    

    But you’ll better fix the real problem by finding which object you use after it’s freed. Try FastMM – it will help you with that task.

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

Sidebar

Related Questions

I have been running into OutOfMemory Exceptions while trying to load an 800MB text
I have a 3.1 xcode project that has been running my app just fine
I have been trying this for hours without success. http://replicaisland.googlecode.com/svn/trunk/ I have added the
I have been writing code like the following enough a lot lately. I don't
I've been using gimite / web-socket-js to implement a WebSocket past simply Chrome and
Background / Disclaimer First of all, please feel free to skip this entirely if
I'm using namespaces in PHP for the first time in an application that provides
I've got an extended WebBrowser control which handles the NewWindow3 event. Originally I wanted
I'm trying to build a streaming .mp3 player to run various sound files on
So, I'm starting a C++ class right now, and I've configured NetBeans (which 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.