Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Building your own memory manager for C/C++ projects

Arpan Sen (arpan@syncad.com), Technical lead, Synapti Computer Aided Design Pvt Ltd
Arpan Sen is a lead engineer working on the development of software in the electronic design automation industry. He has worked on several flavors of UNIX, including Solaris, SunOS, HP-UX, and IRIX as well as Linux and Microsoft Windows for several years. He takes a keen interest in software performance-optimization techniques, graph theory, and parallel computing. Arpan holds a post-graduate degree in software systems. You can reach him at arpansen@gmail.com.
(An IBM developerWorks Contributing Author)
Rahul Kumar Kardam (rahul@syncad.com), Senior Software Developer, Synapti Computer Aided Design Pvt Ltd
Rahul is a senior software developer specializing in developing complex C++-based electronic design automation tools such as simulators for hardware designs. He has programming experience in both Windows and UNIX platforms. Rahul enjoys tinkering with open source software, which he uses as a framework for designing robust, scalable code for the design automation tools he works on. He also enjoys technical writing.

Summary:  Performance optimization of code is serious business. It's fairly common to see a piece of functionally correct software written in C or C++ that takes way too much memory, time, or, in the worst case, both. As a developer, one of the most powerful tools that C/C++ arms you with to improve processing time and prevent memory corruption is the control over how memory is allocated or deallocated in your code. This tutorial demystifies memory management concepts by telling you how to create your very own memory manager for specific situations.

Date:  19 Feb 2008
Level:  Intermediate PDF:  A4 and Letter (83 KB)Get Adobe® Reader®

Activity:  46104 views
Comments:  

Before you start

Learn what to expect from this tutorial and how to get the most out of it.

About this tutorial

This tutorial takes a basic approach to building a memory manager for any application. It explains why a memory manager is needed and provides a few ways in which you can write customized memory managers for an application, catering to its specific needs.


Objectives

In this tutorial, you'll learn what considerations you need to take before designing a memory manager, the specific techniques available for creating such a memory manager, and, finally, the method for creating it. You'll also learn about the advantages and disadvantages of various types of memory manager designs.


Prerequisites

This tutorial is written for Linux® or UNIX® programmers whose skills and experience are at a beginning to intermediate level. You should have a general familiarity with using a UNIX command-line shell and a working knowledge of the C/C++ language. Any additional knowledge of internal workings of routines such malloc, calloc, free, memcpy, and memset (that is, routines that deal with memory allocation, deallocation, and content modification) is a plus.


System requirements

To run the examples in this tutorial, you need a Linux or UNIX box that has the g++ compiler toolchain installed on it. A sufficiently large amount of RAM (approximately 256 MB) is also required.

1 of 14 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=AIX and UNIX, Linux
ArticleID=289930
TutorialTitle=Building your own memory manager for C/C++ projects
publish-date=02192008
author1-email=arpan@syncad.com
author1-email-cc=
author2-email=rahul@syncad.com
author2-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.