1,105,578 Community Members

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

Member Avatar
Fasola
Junior Poster
188 posts since Jan 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
1
 

What's the difference between Static and Dynamic Memory Allocation

and what are the advantages and disadvantages of them both?

Member Avatar
Narue
Bad Cop
12,139 posts since Sep 2004
Reputation Points: 5,693 [?]
Q&As Helped to Solve: 1,537 [?]
Skill Endorsements: 81 [?]
Team Colleague
 
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.

Member Avatar
Fasola
Junior Poster
188 posts since Jan 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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 ;)

Member Avatar
Narue
Bad Cop
12,139 posts since Sep 2004
Reputation Points: 5,693 [?]
Q&As Helped to Solve: 1,537 [?]
Skill Endorsements: 81 [?]
Team Colleague
 
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.

Member Avatar
Fasola
Junior Poster
188 posts since Jan 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

>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*

Member Avatar
Narue
Bad Cop
12,139 posts since Sep 2004
Reputation Points: 5,693 [?]
Q&As Helped to Solve: 1,537 [?]
Skill Endorsements: 81 [?]
Team Colleague
 
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

Member Avatar
Fasola
Junior Poster
188 posts since Jan 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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)

Member Avatar
Real-tiner
Posting Whiz in Training
207 posts since Dec 2004
Reputation Points: 0 [?]
Q&As Helped to Solve: 9 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
samaresh
Newbie Poster
1 post since Jun 2006
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

:mrgreen:

What's the difference between Static and Dynamic Memory Allocation

and what are the advantages and disadvantages of them both?

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article