473,668 Members | 2,487 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Some perfomance thoughts required

Hi!

I've got a pretty complex data structure that keeps instances of
structs allocated with the new operator.
Now my issue is that those structures are required to be allocated /
deallocated pretty often resulting
in a huge perfomance issue. Usually what I am doing is to create
arrays and initialize their sizes a few
times bigger than originally required to avoid another allocation on
the next run. Then I do simply reset them
and do a memcpy at the existing location. This works great with POD
structus but my structs are complex
in the way that they not only use inheritance but they do also use
internal objects that do require an
constructor / destructor. So what is the general way to handle such
things? Am I missing something?

thanks!
Alex
Jun 27 '08 #1
4 1181
On 2008-06-20 11:05, Alexander Adam wrote:
Hi!

I've got a pretty complex data structure that keeps instances of
structs allocated with the new operator.
Now my issue is that those structures are required to be allocated /
deallocated pretty often resulting
in a huge perfomance issue. Usually what I am doing is to create
arrays and initialize their sizes a few
times bigger than originally required to avoid another allocation on
the next run. Then I do simply reset them
and do a memcpy at the existing location. This works great with POD
structus but my structs are complex
in the way that they not only use inheritance but they do also use
internal objects that do require an
constructor / destructor. So what is the general way to handle such
things? Am I missing something?
A pool allocator might help.

--
Erik Wikström
Jun 27 '08 #2
On Jun 20, 10:28*am, Erik Wikström <Erik-wikst...@telia. comwrote:
On 2008-06-20 11:05, Alexander Adam wrote:
Hi!
I've got a pretty complex data structure that keeps instances of
structs allocated with the new operator.
Now my issue is that those structures are required to be allocated /
deallocated pretty often resulting
in a huge perfomance issue. Usually what I am doing is to create
arrays and initialize their sizes a few
times bigger than originally required to avoid another allocation on
the next run. Then I do simply reset them
and do a memcpy at the existing location. This works great with POD
structus but my structs are complex
in the way that they not only use inheritance but they do also use
internal objects that do require an
constructor / destructor. So what is the general way to handle such
things? Am I missing something?

A pool allocator might help.

--
Erik Wikström
Check out boost::object_p ool<T>.

T
Jun 27 '08 #3
In article <3d400f58-1b60-40dc-81bc-01e5e692fdcb@
59g2000hsb.goog legroups.com>, co*****@emiasys .com says...
Hi!

I've got a pretty complex data structure that keeps instances of
structs allocated with the new operator.
Now my issue is that those structures are required to be allocated /
deallocated pretty often resulting
in a huge perfomance issue. Usually what I am doing is to create
arrays and initialize their sizes a few
times bigger than originally required to avoid another allocation on
the next run. Then I do simply reset them
and do a memcpy at the existing location. This works great with POD
structus but my structs are complex
in the way that they not only use inheritance but they do also use
internal objects that do require an
constructor / destructor. So what is the general way to handle such
things? Am I missing something?
You probably want to overload operator new for the class(es) of the
objects you're allocating/freeing so frequently. At startup, your
operator new will grab a big chunk of memory for the data, and break it
up into chunks, each the size of a single object. As objects are
allocated, it'll give out the addresses of object-sized chunks, and mark
each chunk as being in use when it does so. When an object is freed,
it'll mark each chunk as being available again.

You can probably find existing source code for a few different versions
of this -- Andrei Alexandrescu's Loki library has one, and Boost has
another, and so on.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jun 27 '08 #4
Alexander Adam wrote:
Hi!

I've got a pretty complex data structure that keeps instances of
structs allocated with the new operator.
Now my issue is that those structures are required to be allocated /
deallocated pretty often resulting
in a huge perfomance issue. Usually what I am doing is to create
arrays and initialize their sizes a few
times bigger than originally required to avoid another allocation on
the next run. Then I do simply reset them
and do a memcpy at the existing location. This works great with POD
structus but my structs are complex
in the way that they not only use inheritance but they do also use
internal objects that do require an
constructor / destructor. So what is the general way to handle such
things? Am I missing something?

thanks!
Alex
Apart from the other suggestions, you should think about the use of
array as your container data structure, perhaps a node based container
will provide better overall performance, especially when it's memory
intensive.

Fei
Jun 27 '08 #5

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

Similar topics

5
1506
by: SuryaPrakash Patel via SQLMonster.com | last post by:
Dear Reader I am trying to design a database. How can I make best Judgement that Indexing (which I am trying to fix during Diagram Desingning process)is ok. I am able to identify the best candidate for the indexing. Below is the details I want to understand: Area ZIP
4
1733
by: numerous instabilities in deploying VB | last post by:
I have been working on a VB product It is working beautifuly on my XP dev box and my windows 2000 test machines in the lab. When I install at the customer site, I get all kinds of wacky problems that I CANT reproduce in the lab. 1) Some customer PC's can't use ANY functions related to Process = Process.GetProcessById(ProcessID) !!!! - I am resorting to using a 3rd party product to kill process. 2) Sometimes applications will just die...
10
1530
by: George | last post by:
Hi, I have a report which shows all records from database into the browser. The final HTML comes out about 5 Meg. It takes 1 minute 5 seconds for transfer to show up when i hit the page with IE The trace info shows that output was done within 1 second and then i guess it took so much time (> 1 minute) for it to actually be transferred to IE. I am doing test on the same machine. IIS and IE are on the same machine and I believe the actual...
2
1053
by: James T. | last post by:
Hello! Let's say I have 2 functions, both return data from the database. Now I would like to compare perfomance of these two functions. I would like to know how long it takes to execute these functions. How can I do that? Thank you! James
0
1023
by: jambalapamba | last post by:
Hi I am removing node from a document depending on the style property and this is taking 7 seconds for checking complete document is there any ideas how can i improve the perfomance. Here is my part of code foreach (IHTMLElement tempElement in document.all) { if (tempElement.style.visibility == "hidden" ) { IHTMLDOMNode node = tempElement as...
4
1549
by: =?Utf-8?B?VmVlcmFiaGFkcmFpYWggTCBN?= | last post by:
Hi, I have two databases D1 with 6 million records and D2 with 95 thousand records. I need to check Common records from these two databases based on UserID and need to insert into other database D3 and also need to create XML files. For this i followed below approach. I have used two threads. -->one thread to Pick the users from D1, filter out against D2 and will be inserting into D3.
3
3249
by: damodharan | last post by:
Hello and thanks in advance. I have two table in DB2 (ver 8). table details are table one(Cust_det) has two fields (Cust_cin and cust_name). table two(cust_add_det) has cust_cin and cust_address fields. To join above two table which sql is better on perfomance point of view? and how conditional where clause works?
2
1150
by: MickJ | last post by:
Hi, I would like to write High perfomance server using C#. It would be desirable to hear offers and advices on this subject.
0
1189
by: ferozanna | last post by:
I am using Asp.net 1.3 with C# My application used by call center people My applicaton is a three tier arch I have create data layer as class ibrary which goint to talke Ssqlserver 205 db At time 2000 to 3000 user are using How can i improve my application perfomance, Give me tips
0
8893
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8799
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8586
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7401
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6209
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5681
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4205
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4380
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.