Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

What's Dynamically Allocated Memory?

Status
Not open for further replies.

fireflies

Newbie level 5
Newbie level 5
Joined
Feb 1, 2006
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,350
What's Dynamically Allocated Memory? Can someone explain it? The book doesn't say much but just talks about 'new' and 'delete'.

Thanks.
 

dynamically allocated memory is the memory allocated in heap at run-time.

see http://en.wikipedia.org/wiki/Heap_(programming)

In computer science, dynamic memory allocation is the allocation of memory storage for use in a computer program during the runtime of that program. It is a way of distributing ownership of limited memory resources among many pieces of data and code. A dynamically allocated object remains allocated until it is deallocated explicitly, either by the programmer or by a garbage collector; this is notably different from automatic and static memory allocation. It is said that such an object has dynamic lifetime.

The Need:
-------------
It is desirable to dynamically allocate space for variables at runtime. It is wasteful when dealing with array type structures to allocate so much space when declared, eg,
struct client clients[100];
This practice may lead to memory contention or programs crashing. A far better way is to allocate space to clients when needed.
The C programming language allows users to dynamically allocate and deallocate memory when required. The functions that accomplish this are calloc(), which allocates memory to a variable, sizeof, which determines how much memory a specified variable occupies, and free(), which deallocates the memory assigned to a variable back to the system.

hope i am clear
Ivar
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top