C ++ Memory Allocation Method

Source: Internet
Author: User

Http://hi.baidu.com/keeekee/blog/item/95564b7a34c3d0ee2e73b3ae.html

1. allocated from the static storage area.

InnerProgramIt is allocated during compilation. This program exists throughout the running period.

Such as global variables and static variables.

2. Create a stack.

When executing a function, all the storage units of local variables in the function can be created on the stack;

These storage units are automatically released at the end of function execution.

Stack memory allocation operations are embedded in the processor's instruction set. High efficiency, but the allocated memory capacity is limited.

3. Allocate from the stack, also known as dynamic memory allocation.

When the program is running, use malloc or new to apply for any amount of memory,

The programmer is responsible for releasing the memory with free or delete.

The lifetime of the dynamic memory is specified by us.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.