By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,934 Members | 1,804 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,934 IT Pros & Developers. It's quick & easy.

Dynamic allocation to static memory allocation

P: 2
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
Share this Question
Share on Google+
3 Replies


P: 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

P: 2
Hi,

My compiler is Microsoft Visual C++ 6.0.

Thanks
May 7 '07 #3

P: 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

Post your reply

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