954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Static and Dynamic Memory Allocations...Advan's & Disadvan's???

What's the difference between Static and Dynamic Memory Allocation

and what are the advantages and disadvantages of them both?

Fasola
Junior Poster
188 posts since Jan 2005
Reputation Points: 11
Solved Threads: 0
 

Static allocation is fast, but set in stone. Dynamic allocation is slower, but you can grab varying chunks. This sounds a lot like a homework question.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

nah, its not homework. I've been out of school for almost 2 yrs now and haven't coded in 3. i was reading up on it for this Software Engineer position and i could only find Dynamic Memory Allocation. There was nothing on Static memory allocation. So, i made a thread up. I told you this is going to be a second home for me. Thinking about getting a computer with there's still a flat panel special at Dell

thanx a lot as usual ;)

Fasola
Junior Poster
188 posts since Jan 2005
Reputation Points: 11
Solved Threads: 0
 

Static memory allocation is called a bunch of different things, whereas dynamic memory allocation is the term that's used most often for that concept.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

>Static memory allocation is called a bunch of different things

hmmmmm...i think i saw something on static data storage. Is that the same thing?


oh i have my answers to that code i put up i'll put it up real soon

*about to type it up now*

Fasola
Junior Poster
188 posts since Jan 2005
Reputation Points: 11
Solved Threads: 0
 

It depends on the context. If we're talking about the structure of an executable file, then it's not the same. If we're talking about variables not allocated by new or malloc, then it probably is the same. If we're talking about linkage, then get ready to be confused. ;) I'm still not sure I understand linkage in C and C++. :D

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

i'm already confused lol

you lost me at >structure of an executable file

but let me type this code up real quick so you can see the answers, i think there was an error in the question they gave me (i'll explain later)

Fasola
Junior Poster
188 posts since Jan 2005
Reputation Points: 11
Solved Threads: 0
 

Static allocation is done at the time the program is written. The programmer reserves a set amount of memory for each use. That setting will be used each time the program runs.

Dynamic allocation is done while the program runs, adjusting the amount of memory for each use according to how much memory that use actually needs AT THIS TIME.

Real-tiner
Posting Whiz in Training
207 posts since Dec 2004
Reputation Points: 11
Solved Threads: 8
 

:mrgreen: What's the difference between Static and Dynamic Memory Allocation

and what are the advantages and disadvantages of them both?

samaresh
Newbie Poster
1 post since Jun 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You