473,395 Members | 2,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

STL custom allocator design

Where would I go to learn how to create a custom STL allocator? I want to
manage memory in a particular way for certain containers.

-dr
Jan 31 '07 #1
4 7627
Dave Rahardja wrote:
Where would I go to learn how to create a custom STL allocator? I want to
manage memory in a particular way for certain containers.

-dr
Here's an example:

http://www.josuttis.com/libbook/memory/myalloc.hpp.html

Now modify to fit your needs.
Jan 31 '07 #2
Dave Rahardja wrote:
Where would I go to learn how to create a custom STL allocator? I want to
manage memory in a particular way for certain containers.

-dr
Josuttis has some sample code online from his book "The C++ Standard
Library - A Tutorial and Reference". Obviously the book would help to
put it all into context, but the sample code is straightforward and has
a lot of comments:
http://www.josuttis.com/libbook/memo...lloc1.cpp.html

--
Alan Johnson
Jan 31 '07 #3
What would be the benefit of creating a custom allocator for an STL
container?

Cheers, Henry

--------
http://hamath.blogspot.com - Science, technology, and interesting
stuff Blog

Feb 1 '07 #4
On 31 Jan 2007 20:09:21 -0800, "ga********@gmail.com" <ga********@gmail.com>
wrote:
>What would be the benefit of creating a custom allocator for an STL
container?
In an embedded system that must contend with both long uptimes and small
amounts of memory, it is often beneficial to manage dynamic memory allocation
"by hand". I'd still like to use vector, string, etc., but I'd like to
constrain how the memory is allocated (e.g. from a pool or section of memory).

-dr
Feb 1 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Brian Genisio | last post by:
Hi all, I am developing some software, that creates a tree of information. For each node, currently I am overriding the new operator, because it is a requirement that after initialization, no...
15
by: Alex Vinokur | last post by:
I am looking for any custom allocator sample code for std::vector. Thanks. -- Alex Vinokur http://mathforum.org/library/view/10978.html http://sourceforge.net/users/alexvn
15
by: natespamacct | last post by:
Hi All, I'm not sure if I'm dealing with a C++ question or a compiler question, so please forgive me if I'm asking in the wrong spot. If so, maybe someone can direct me to more appropriate spot....
4
by: Romeo Colacitti | last post by:
I have a need to make a custom quasi-memory allocator, and I remembered a simple ons in K&R2. Looking at the code for it now, I think I notice a "fault" in the design, and I was wondering if...
4
by: Robert Frunzke | last post by:
Hello, I need to implement a custom allocator to speed up the allocation of a specific class in my project and instead of hardwiring it, I would "templatize"(?) it. The allocator should have...
3
by: Alex Vinokur | last post by:
Compiler GNU g++ version 3.4.4 (cygming special) Custom allocator for vector (see below) checks a return value of 'operator new'. If that value is NULL, the allocator "allocates" no memory....
3
by: joe | last post by:
I have written a custom std allocator which follows the example in Stroustrup's book. I'm seeing a behavior I don't understand. My allocate method within the allocator looks like the...
2
by: ranin02 | last post by:
Hi, We have a list derived from std::list that has a custom allocator derived from std::allocator. This was originally written using VC++ 6.0 which required a workaround for the fact that 6.0...
2
by: Juha Nieminen | last post by:
If we have a custom allocator (eg. given to us as a template parameter), the proper way of allocating an object using it is like: Allocator alloc; Allocator::pointer ptr = alloc.allocate(1);...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.