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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:43:55+00:00 2026-05-25T18:43:55+00:00

I have a simple program which reads a bunch of ini file settings in

  • 0

I have a simple program which reads a bunch of ini file settings in memory allocated dynamically (malloc), then does stuff in loops for a long time, then ends. When I run valgrind I see that the memory I malloc’ed for my ini strings is not freed.

On the one hand, I think that it shouldn’t matter since the program is shutting down (and no memory is leaked in the loops).

On the other hand, I like when valgrind gives me a big pat on the back for cleaning up my own mess. Aside from the pat on the back…is it good practice to release every malloc’ed space upon termination (or just let the OS cleanup)? If it is, how can I track which of my pointers point to malloc’ed memory (versus pointing to string constants which are the defaults) to ensure I’m releasing the right stuff?

  • 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-25T18:43:55+00:00Added an answer on May 25, 2026 at 6:43 pm

    The main advantage to freeing mallocs at shutdown is to help valgrind track down your memory leaks – you can’t find true memory leaks when you have pages full of false positives, after all. Apart from that, though, there’s no harm in letting the OS clean up.

    As for keeping track of string constants vs heap allocated values, one simple policy would be to always use heap values – fill in the defaults with strdup()d strings at startup.

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

Sidebar

Related Questions

I have a simple Java program which reads a file directory and outputs a
I have a simple spring batch program which reads data from a INPUT file
I have a simple Delphi program that I'm working on, in which I am
I have been trying to create a simple program with Python which uses OpenCV
I have a simple script which is used to start another program. This other
I have a simple program that creates a thread, loops twenty times and then
I have a wxPython program which reads from different datasets, performs various types of
I have a simple program which starts n threads and create some load on
I have a very simple pure html file in which I have many PDF
I have a simple Python program which uses a read-eval-print loop to read user

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.