c编译的程序占用的内存(C compiled programs take up memory).docVIP

  • 4
  • 0
  • 约1.44万字
  • 约 16页
  • 2017-08-31 发布于河南
  • 举报

c编译的程序占用的内存(C compiled programs take up memory).doc

c编译的程序占用的内存(C compiled programs take up memory)

c编译的程序占用的内存(C compiled programs take up memory) C compiled programs take up.Txt of memory A program compiled by c/C++ occupies the following sections of memory 1, the stack area (stack) - the program runs automatically by the compiler allocation, storage function parameters, local variables and so on. Its operation is similar to the stack in the data structure. At the end of the program, it is automatically released by the compiler. 2, heap area (heap) - open another storage area in memory. Generally distributed by programmer, if the programmer does not release, the program may be recycled by OS at the end of the program. Notice that it is different from the heap in the data structure, but the distribution method is similar to the linked list. 3, global (static) (static) - the compiler allocates memory when it is compiled. Global and static variables stored is placed on a piece of the initialization of global and static variables in a region, uninitialized global variables and static variables uninitialized in another area adjacent to the. - release of the system after the program is finished 4, the text constant area - constant string is placed here. The system is released at the end of the program 5, program code area - the binary code that holds the function body. Example program It was written by a senior, very detailed //main.cpp Int a = 0; global initialization area Char *p1; global uninitialized region (main) { Int b; / / stack Char s[] = ABC; / / stack Char *p2; / / stack Char *p3 = 123456; / / 123456\0 in the constant region, P3 on the stack. Static int c =0; / / global (static) initialization zone P1 = (char *) malloc (10); P2 = (char *) malloc (20); The distribution of 10 and 20 / more bytes in the area heap area. Strcpy (P1, 123456); //123456\0 is placed in the constant section, and the compiler might optimize it with the 123456 point P3 points to. } =============== Memory allocation in C language programs 1. memory allocation There are three ways to all

文档评论(0)

1亿VIP精品文档

相关文档