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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:11:39+00:00 2026-05-17T22:11:39+00:00

I tend to use std *alloc/free functions to allocate/free dynamic memory in my C

  • 0

I tend to use std *alloc/free functions to allocate/free dynamic memory in my C programs.
I wonder if there are any good reasons to use the GLIB Memory Allocation functions instead of the std ones.

I’d be grateful if the comunity could point out situations where either of these solutions is a winner/looser. I am also interested in performance issues that I could hit in case I use one or the other.

Thanks !

Edited to state platforms

These programs normally run on all type of Linux/Unix distributions, normally 64 bits archs compiled using gcc 4.2.

  • 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-17T22:11:40+00:00Added an answer on May 17, 2026 at 10:11 pm

    In my opinion, the most valuable difference between the GLib functions and the standard library ones is that the GLib functions abort the program if the allocation fails. No more checking to see if the return value from malloc() is NULL! Other than that, there’s no difference in allocation strategy – g_malloc() calls malloc() internally, though as one of the other answers here states, it is possible to change that.

    Another difference is that the GLib functions allow you to have (rudimentary) memory leak checking using g_mem_profile().

    GLib also has a slice allocator, which is more efficient if you are allocating many equal-sized chunks of memory. This doesn’t use the system malloc() and free(), but again, it is possible to change that for debugging purposes.

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

Sidebar

Related Questions

Is there any particular reason to use one over the other? I personally tend
At my workplace, we tend to use iostream , string , vector , map
In new C++ code, I tend to use the C++ iostream library instead of
When debugging web sites that I'm working on, I tend to use Attach to
I was curious about how other people use the this keyword. I tend to
I always tend to forget these built-in Symfony functions for making links.
I tend to use POSIX Threads , when programming in C, under Linux .
I tend to use If Not IsDBNull(dr(data)) Then myData = dr(data) End If to
I'm on an optimization kick, at the moment. I tend to use multiple tables,
I tend to use it whenever I am working on a prototype script, and:

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.