473,221 Members | 1,574 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,221 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 1711
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.