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

Is dynamic Memory allocation- most effective one?

Diff b/w Static and Dynamic Memory allocations?

which var(Static/dynamic) is to be used to create a application for the embedded Environment?

which one is most effective one for a embedded linux environment ?
Jul 27 '07 #1
5 1716
JosAH
11,448 Expert 8TB
Diff b/w Static and Dynamic Memory allocations?

which var(Static/dynamic) is to be used to create a application for the embedded Environment?

which one is most effective one for a embedded linux environment ?
If the device is able to run Linux it is big enough to support simple dynamic
memory (malloc/free). There's no need to worry about it.

kind regards,

Jos
Jul 27 '07 #2
thanks Jos

i want know about,
how the calloc/malloc Vs static var works with memory?
how the processes using stack/heap memory ?

can you explain me on this plz,

thanks
Balaji
Jul 27 '07 #3
JosAH
11,448 Expert 8TB
thanks Jos

i want know about,
how the calloc/malloc Vs static var works with memory?
how the processes using stack/heap memory ?

can you explain me on this plz,

thanks
Balaji
There's nothing magic about the two: static memory is already present when
your process starts, i.e. for every single global variable there's memory available
for it already. Dynamic memory management simply asks chunks/pages of
memory from the OS and hands it out to your process piecemeal when malloc
requests for it.

kind regards,

Jos
Jul 27 '07 #4
There's nothing magic about the two: static memory is already present when
your process starts, i.e. for every single global variable there's memory available
for it already. Dynamic memory management simply asks chunks/pages of
memory from the OS and hands it out to your process piecemeal when malloc
requests for it.

kind regards,

Jos

Embedded linux in the sense core have own fixed memory for montavista like linux and it is having some minimum size of memory only.also i want the processing time for the application is less i.e., faster response.
Here application means, which we are creating with some c code ( that have code like mem allocation, some more req operations and freeing it at last).

I want to know some details about internal things, like how memory allocation happening with memory for the static and dynamic memory allocations during which (build /run) time ?

which process will take time to allocate mem either static or dynamic?
I thought dynamic memory will take more time than static.. And it will do some more internal processes.. is it? can plz you explain me on this?
Jul 29 '07 #5
JosAH
11,448 Expert 8TB
I think you're overcomplicating matters here: after your process has been loaded
into memory, your initialized global variables are ready to be used. The other,
noninitialized global variables end up in a block of memory for which all bits are
set to zero.

Next a 'heap' is constructed: first the 'brk()' or 'sbrk()' system call allots a block
of memory to your process. This will be the initial heap. All the malloc'd memory
comes from this heap and is returned to this heap when free'd. Note that nothing
moves in there; i.e. just a few pointer values are fiddled with.

When more memory is needed for the heap, brk() or sbrk() is called again; some
heap management schemes are clever enough to return memory to the OS
again, again using these same system calls (check the man pages).

Basically you refer to that heap memory (dynamic memory) through pointers
just because you don't know in advance *where* in memory your allocated
memory will be present.

There are no other processes involved for your process' heap management,
in fact that management is part of your process, it was (dynamically?) linked
in to your process.

kind regards,

Jos
Jul 29 '07 #6

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

Similar topics

9
by: Tom | last post by:
What I mean is why can I only allocate const size stuff on the stack in C++? If I want to allocate a variable amount I need to use the OS API (Win32 in my case). Thanks, Tom.
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...
6
by: Sandeep Chikkerur | last post by:
Hi, If the entire heap memory for dynamic allocation is not available, does the compiler always return NULL ? eg: char *s; s = (char *)malloc(...);
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...
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...
3
by: ranjeetasharma81 | last post by:
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...
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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...

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.