Results 1 to 6 of 6

Thread: Memory allocation in C++

  1. #1
    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.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    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.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    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.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    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

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    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.

  6. #6
    Join Date
    Oct 2005
    Posts
    2,393

    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.

Similar Threads

  1. Memory allocation of new object
    By Miles Runner in forum Software Development
    Replies: 5
    Last Post: 09-03-2010, 10:18 AM
  2. Memory allocation and management
    By AdityaR in forum Software Development
    Replies: 4
    Last Post: 22-01-2010, 08:42 PM
  3. Memory allocation optimized bitwise
    By Ricky58 in forum Software Development
    Replies: 3
    Last Post: 07-05-2009, 10:53 AM
  4. Memory Allocation Techniques for declaring objects
    By Gill_christ in forum Software Development
    Replies: 2
    Last Post: 04-05-2009, 07:21 PM
  5. SBSMonitoring/SQL Memory allocation error (run away Memory usage)
    By Dilbert in forum Small Business Server
    Replies: 1
    Last Post: 21-09-2005, 11:32 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,502,346.76871 seconds with 16 queries