473,783 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

require some memory allocation advice ....

I have a big dynamic sparse directed graph implementation where new
nodes are added & old nodes are removed. Usually, at any moment of
time the number of nodes in the graph and the number of edges are
approximately constant. The nodes and associated data are stored in a
quasi-static dynamic memory (quasi_buffer) which reserves a minimum
memory, but on demand can grow upto an user defined maximum memory.
The no of nodes in the graph are approx (N = 6000000) , while the no
of edges per node are approx 40-45, connected to mostly recently
arrived nodes, and number of properties (name value pair stored in
map) per node approx 24.
Each node has its local data, a set of parameter maps (std::map with
name value pair) and a list of linked vertex (std::vector). Both of
them are small dynamic memory per vertex.
so the codes are like,
///This is position structure, to get position from quasi_buffer
struct pos{
std::size_t index;///the index to quasi_buffer including history.
quasi_buffer<no de>* buffer;
pos(quasi_buffe r<node>& b,std::size_t i) : buffer(&b),inde x(i){}
std::size_t relative_pos()c onst{ return index-
(*buffer).num_r emoved();}
};
struct node{
std::vector<pos edges;///vector has dynamic memory
std::map<Name,V alueprop;///map has dynamic memory
///Name is enum, Value is a small struct(no dynamic memory)
///other local data (which doesn't have any dynamic memory)
int type;
int processState;
};
typedef quasi_buffer<no degraph;
The graph visualization is like, and most of the edges are
connected nearby nodes (in memory & in time) The numbers are node
numbers for connection.
add node<---------- graph nodes ---------remove node (time line)
1 2 3 4 5 6 7 8 9 10 11 12 13
--- --- --- --- --- --- --- --- --- --- --- --- ---
|1 |1 |1 |3 |4 |5 |5 |6 |10 |11 |10 |13 |10
|2 |2 |5 |6 |6 |7 |12 |11 =>
connecting node list
|4 |7 |8 |9 |12
|9
in memory the nodes may be like
6 7 8 9 10 11 12 13 1 2 3 4 5 , i.e folded in a circular fashion.

Now my questions are,
1) can i have an allocator which allocates all these small vectors in
approximately FIFO way (there can be some holes in the FIFO list, as
some of the old nodes may be still referred) so that it can works
without too many allocation /deallocation calls?
At present i am not doing too much performance measure, but i want to
check if the concept works.
i think i need a statefull allocator, which can allocate multiple
vectors and maps from same pool (perhaps using some static data?).
2) as the number of nodes can rarely increase to a large extent or
shrink to a small, causing the nodes to be moved to a new memory (much
like vector). In this case as all the nodes are copied to a new memory
(N node struct), so the vectors & maps which ware stored in the node
are also copied (this is approx 40*N pos struct + N maps with approx
20 elements). However it can be done with only exchanging the internal
pointers for them like swap. Can the node's copy constructor be
implemented to facilitate this (i don't use at present the copy
ctors)?
This will be kind of proposed "move " ?

Thanks
abir
Jul 17 '08 #1
0 1341

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

Similar topics

18
6681
by: Tron Thomas | last post by:
Given the following information about memory management in C++: ----- The c-runtime dynamic memory manager (and most other commercial memory managers) has issues with fragmentation similar to a hard drive file system. Over time, the more often use call new/delete or alloc/free, there will be gaps and fragments in the heap. This can lead to inefficient use of available memory, as well as cache-hit inefficiencies.
5
1695
by: Lionel | last post by:
Hi all, Just wondering exactly how memory is allocated using the new operator? More specifically I am interested in how the memory is calculated for globable variables? I recently stumbled into a problem which corrected my way of thinking. Now, people probably won't be able to answer much to that question, so I will give an example. This is example uses the qt library qstring.h, but I assume this would be similar to the C++ string.h...
16
2520
by: Jacob | last post by:
It is common practice (I've heard) to always catch allocation exceptions from "new". How is done in practice? What would be a common procedure (path of sequence) after such an event has occured? (For a multi-million LOC, GUI based application). It is also a common advice not to allocate objects with "new" unless absolutely required. The alternative is to keep objects on the stack, automatically allocated and deallocated by scope...
24
19096
by: Ken | last post by:
In C programming, I want to know in what situations we should use static memory allocation instead of dynamic memory allocation. My understanding is that static memory allocation like using array is faster than malloc, but dynamic memory allocation is more flexible. Please comment... thanks.
81
4576
by: Peter Olcott | last post by:
It looks like System::Collections::Generic.List throws and OUT_OF_MEMORY exception whenever memory allocated exceeds 256 MB. I have 1024 MB on my system so I am not even out of physical RAM, much less virtual memory. Are other people experiencing this same problem?
17
9149
by: dtschoepe | last post by:
Hi, I have a homework project I am working on, so be forwarned, I'm new to C programming. But anyway, having some trouble with a memory allocation issue related to a char * that is a variable inside of a structure. I keep getting segmentation fault errors and I am having trouble understanding why. Here's the parts of the code in question... This is part of the .h file where the struct us defined...
1
7978
by: Peterwkc | last post by:
Hello all expert, i have two program which make me desperate bu after i have noticed the forum, my future is become brightness back. By the way, my problem is like this i the first program was compiled and run without any erros but the second program has a run time error when the function return from allocate and the ptr become NULL. How to fixed this? Second Program: /* Best Method to allocate memory for 2D Array because it's ...
9
2519
by: weidongtom | last post by:
Hi, I've written the code that follows, and I use the function add_word(), it seems to work fine *before* increase_arrays() is called that uses realloc() to allocate more memory to words. But *after* calling increase_arrays(), I received segmentation fault. I tried to step it through gdb, and I found out that after calling increase_arrays(), words's original value is modified, and if I tried to access it, I get <address 0x11 out of...
11
3581
by: Bryan Parkoff | last post by:
I want to know how much static memory is limited before execution program starts. I would write a large array. The large array has 65,536 elements. The data size is double word. The static memory would allocate 256K. The 256K is a fixed memory size. After the compiler has completed compiling header and source code, the execution program might fail to run or crash. The operating system might do not display error message saying,...
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10313
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
10147
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
10081
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
8968
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
7494
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
6735
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
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.