473,395 Members | 1,941 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.

Can I improve efficiency of 50.000 "new"'ed objects?

Is there features/containers of standard C++ or the STL which will
assist in minimizing memmory fragmentation upon creation of a huge
ammount of objects on the heap?

Currently my application allocates 50.000 objects using "new". I can
store the pointers to those objects in a container/collection class and
indeed this assists in processing (sort, delete etc.) but is there any
way for me to make my "new"'ed object resist in some previously
allocated memmory chunk to improve performance (allocate in bigger
chunks) and avoid memmory fragmentation at the same time?

Just one example of the inefficiency is when I delete my objects, I have
to loop through all and "delete" instead of simply delete in one big
chunk. Obviously I can not use "delete[]" as this would only delete my
array and leave me with a massive memmory leak.

And pointers greatly appreciated!
/Casper
Jul 22 '05 #1
4 1677
"Casper" <ca****@jbr.dk> wrote in message
news:Xo*********************@weber.videotron.net.. .
Is there features/containers of standard C++ or the STL which will
assist in minimizing memmory fragmentation upon creation of a huge
ammount of objects on the heap?

Currently my application allocates 50.000 objects using "new". I can
store the pointers to those objects in a container/collection class and
indeed this assists in processing (sort, delete etc.) but is there any
way for me to make my "new"'ed object resist in some previously
allocated memmory chunk to improve performance (allocate in bigger
chunks) and avoid memmory fragmentation at the same time?

Just one example of the inefficiency is when I delete my objects, I have
to loop through all and "delete" instead of simply delete in one big
chunk. Obviously I can not use "delete[]" as this would only delete my
array and leave me with a massive memmory leak.


What are these objects? Are these objects all of the same type? If they
are, then a std::vector can store them contiguously. If not, then things
might be more difficult.

--
David Hilsee
Jul 22 '05 #2
"Casper" <ca****@jbr.dk> wrote in message
news:Xo*********************@weber.videotron.net.. .
Is there features/containers of standard C++ or the STL which will
assist in minimizing memmory fragmentation upon creation of a huge
ammount of objects on the heap?

Currently my application allocates 50.000 objects using "new". I can
store the pointers to those objects in a container/collection class
and indeed this assists in processing (sort, delete etc.) but is
there any way for me to make my "new"'ed object resist in some
previously allocated memmory chunk to improve performance (allocate
in bigger chunks) and avoid memmory fragmentation at the same time?

Just one example of the inefficiency is when I delete my objects, I
have to loop through all and "delete" instead of simply delete in
one big chunk. Obviously I can not use "delete[]" as this would only
delete my array and leave me with a massive memmory leak.


In his book, Modern C++ Design, Andrei Alexandrescu implements a
"Small-Object Allocator". I recommend you buy the book, but you can
download Loki (the library where he implemented everything in the
book) from SourceForge. I believe you can modify it to suit your
needs, even though it might be good enough as it is.

Vladimir Ciobanu
Jul 22 '05 #3
Search for "pool allocation".

Thierry Miceli
www.ideat-solutions.com

Jul 22 '05 #4
IIRC there is a pool allocator in Boost that can be useful too.

VH
Jul 22 '05 #5

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

Similar topics

18
by: Leslaw Bieniasz | last post by:
Cracow, 28.10.2004 Hello, I have a program that intensively allocates and deletes lots of relatively small objects, using "new" operator. The objects themselves are composed of smaller...
24
by: Rv5 | last post by:
Rookie c++ question, but Ive spent the last 5 years doing Java, where everytime I created an object I used new. In c++ I can create my objects without and its confusing me just a little. I have...
51
by: Tony Sinclair | last post by:
I'm just learning C#. I'm writing a program (using Visual C# 2005 on WinXP) to combine several files into one (HKSplit is a popular freeware program that does this, but it requires all input and...
37
by: jht5945 | last post by:
For example I wrote a function: function Func() { // do something } we can call it like: var obj = new Func(); // call it as a constructor or var result = Func(); // call it as...
14
by: mlw | last post by:
Do not take anything about this, it is not a flame or troll, while I'm not new to Java I favor C++. However, I may need to use it in a contract position, and am concerned that the restrictions it...
36
by: Pat | last post by:
Hi, I've run into a strange problem, but one that seems like it might be fairly common. I have a single base class, from which several other classes are derived. To keep the example simple,...
4
by: sevenever | last post by:
It seems leads to memory leaking on windows + VC. The delete will not free the memory in such condition?
350
by: Lloyd Bonafide | last post by:
I followed a link to James Kanze's web site in another thread and was surprised to read this comment by a link to a GC: "I can't imagine writing C++ without it" How many of you c.l.c++'ers use...
30
by: Medvedev | last post by:
i see serveral source codes , and i found they almost only use "new" and "delete" keywords to make they object. Why should i do that , and as i know the object is going to be destroy by itself at...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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:
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.