473,396 Members | 1,894 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,396 software developers and data experts.

Dynamic allocation to static memory allocation

Hi all,

I have a big C-cod, in which there are lots of dynamic memory allocation used. I want to replace dynamic memroy allocation by static arrays. The following are the problems that i am facing:

1- From structure and dynamic memory allocation point of view, the code is
very complicated. The code has various “nested structures” with a number
of levels. The size of memory allocated for pointer to structure or its
pointer structure member is calculated at “run time”. That size may vary
at different modes.
2- Different levels of structure are being allocated memory at different
places within the code.
3- If we consider any structure, there are two possibilities:
a) It is used as a part of any other structure, or
b) Different individual pointers of type structure are defined, which are being allocated memory at different places with different sizes (which may again in turn vary for different modes) that are calculated at run time. Since size is adaptive, it is very difficult to calculate the minimum size required to be llocated for each structure and array. Is there any software available to do so??

Even if we are able to find the size and allocate the maximum size to different structure and its member, it will be not be the optimum utilization of memory since at the moment in the code, the minimum required memory is calculated every time and only that much is allocated. But one of my senior ask me to do so. Is it going to be benificial some how??

The process seems to be quite complicated and I dont know where to start with and how. I am very confused. Any help will be appriciated .

Thanks
Ranjeeta
May 4 '07 #1
3 2933
ajayraj
21
Hi all,

I have a big C-cod, in which there are lots of dynamic memory allocation used. I want to replace dynamic memroy allocation by static arrays. The following are the problems that i am facing:

1- From structure and dynamic memory allocation point of view, the code is
very complicated. The code has various “nested structures” with a number
of levels. The size of memory allocated for pointer to structure or its
pointer structure member is calculated at “run time”. That size may vary
at different modes.
2- Different levels of structure are being allocated memory at different
places within the code.
3- If we consider any structure, there are two possibilities:
a) It is used as a part of any other structure, or
b) Different individual pointers of type structure are defined, which are being allocated memory at different places with different sizes (which may again in turn vary for different modes) that are calculated at run time. Since size is adaptive, it is very difficult to calculate the minimum size required to be llocated for each structure and array. Is there any software available to do so??

Even if we are able to find the size and allocate the maximum size to different structure and its member, it will be not be the optimum utilization of memory since at the moment in the code, the minimum required memory is calculated every time and only that much is allocated. But one of my senior ask me to do so. Is it going to be benificial some how??

The process seems to be quite complicated and I dont know where to start with and how. I am very confused. Any help will be appriciated .

Thanks
Ranjeeta
Please mention the compiler you are using?
May 4 '07 #2
Hi,

My compiler is Microsoft Visual C++ 6.0.

Thanks
May 7 '07 #3
ajayraj
21
Hi,

My compiler is Microsoft Visual C++ 6.0.

Thanks
Then you can use the tool available here
http://www.codeproject.com/tools/leakfinder.asp
its actually for finding the memory leak of the code,
but u can get the status of the heap allcation too.
So try it out.
It will help you.
May 8 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: chris | last post by:
Hi all, I need to know, what is the difference between dynamic memory allocation, and stack allocation ? 1. If I have a class named DestinationAddress, when should I use dynamic memory...
5
by: swarsa | last post by:
Hi All, I realize this is not a Palm OS development forum, however, even though my question is about a Palm C program I'm writing, I believe the topics are relevant here. This is because I...
13
by: xian_hong2046 | last post by:
Hello, I think dynamic memory allocation is supposed to be used when one doesn't know in advance how much memory to allocate until run time. An example from Thinking in C++ is to dynamically...
11
by: toton | last post by:
Hi, I have little confusion about static memory allocation & dynamic allocation for a cluss member. I have class like class Bar{ public: explicit Bar(){ cout<<"bar default"<<endl; }
24
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...
7
by: Jo | last post by:
Hi, How can i differentiate between static and dynamic allocated objects? For example: void SomeFunction1() { CObject *objectp = new CObject; CObject object;
1
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...
14
by: vivek | last post by:
i have some doubts on dynamic memory allocation and stacks and heaps where is the dynamic memory allocation used? in function calls there are some counters like "i" in the below function. Is...
10
by: swornavidhya.mahadevan | last post by:
Which allocation (Static / Dynamic) is suitable for the situation when we are trying to allocate for a overloaded memory when the memory is full and no space to allocate. What will happen if both...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
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,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.