Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , , ,

Sponsored Links



Memory allocation in C++

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 08-02-2010
Member
 
Join Date: Dec 2009
Posts: 48
Memory allocation in C++

Hello Guys,

I just started the C++ programming. The memory management concept of C++ seems quit complicated to understand. I am not able to understand the "memory allocation" concept of C++. How does 'memory allocation' can be implemented in C++ language?. If you knows anything about the 'Memory allocation' in C++, then please let know that. I would greatly appreciate your any help over this concept.
Reply With Quote
  #2  
Old 08-02-2010
Praetor's Avatar
Member
 
Join Date: Apr 2008
Posts: 1,937
Re: Memory allocation in C++

In C++, three memory allocation strategies can be employed: static allocation, dynamic allocation on the stack, and dynamic allocation on the heap. The static allocation is mainly due to compiled programming languages. The interpreted languages can not, by definition, that allocating memory on demand, at run time. In each of the strategies is an area of memory program, or segment. These segments are called text (static) stack (battery) and heap (heap). The transaction symmetric allocation is commonly called release memory.
Reply With Quote
  #3  
Old 08-02-2010
Member
 
Join Date: May 2008
Posts: 1,990
Re: Memory allocation in C++

The advantage of static memory allocation of C++ is that, at the level of performance, since it avoids the costs of the dynamic allocation at run time( the static memory is immediately usable). Static memory allocation provide memory space before running the program, specifying the amount required in the source code.In this type of memory allocation essential to load the program into memory, just before the execution, the space becomes available.
Reply With Quote
  #4  
Old 08-02-2010
kelfro's Avatar
Member
 
Join Date: Apr 2008
Posts: 1,976
Re: Memory allocation in C++

Hi friend,

The C++ offers four operators for to achieve 'Memory allocation':
  • delete []ptr: Deletes an array of objects
  • new Item: creates an object
  • new object[n] : Creates an array of n object (s)
  • delete ptr: Deletes an object
Reply With Quote
  #5  
Old 08-02-2010
Zecho's Avatar
Member
 
Join Date: May 2008
Posts: 2,267
Re: Memory allocation in C++

The memory allocation on the stack must be chosen in priority when the memory needs are known in advance and are proportional to some input parameters of the program. The allocation and subsequent release, according to a disciplinary cell, large amounts of memory can cause performance problems and readability of the source (explosion in the number of parameters passed to functions). These problems are put in the balance cons insurance a proper release of memory resources.
Reply With Quote
  #6  
Old 08-02-2010
Reegan's Avatar
Member
 
Join Date: Oct 2005
Posts: 2,299
Re: Memory allocation in C++

Hi friend,

In C++ the memory allocation on the heap allows complete control of arbitrary allocation and release, offering the most potential. The resources were manually however indefinite life, that is to say that the programmer is responsible for the release (and must avoid the pitfalls of dual release, etc.). The memory allocated on the heap can also be referenced by global variables (preferably in a confined Namespace), Which can help relieve a group of functions common parameters.
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Memory allocation in C++"
Thread Thread Starter Forum Replies Last Post
Memory allocation of new object Miles Runner Software Development 5 09-03-2010 10:18 AM
Memory allocation and management AdityaR Software Development 4 22-01-2010 08:42 PM
changing video memory allocation? help ChumsGum Vista Help 4 22-06-2009 08:39 PM
inetinfo.exe memory allocation cmjkeegan Small Business Server 5 14-02-2006 03:28 PM
SBSMonitoring/SQL Memory allocation error (run away Memory usage) David Gill Small Business Server 1 21-09-2005 12:32 PM


All times are GMT +5.5. The time now is 04:19 AM.