Question about heap and stack memory usage

On Windows, the stack memory is a thread-specific storage, and the call stack is the logical thread of a series of methods. Thus, each thread has its own stack area. I want to know how memory heap area is used? Does it depend on the flow? Process specific? Or in .NET, specific to AppDomian? Or is it used for all user applications and the operating system? Many thanks.

+3
source share
3 answers

A heap is the most common way to implement dynamic memory allocation. A typical heap usage scenario involves when you do not know how much memory is allocated before runtime, or if the required memory is too large to be allocated on the stack.

A process can contain one or more heaps. Most processes have more than heaps. For example, on Windows, a process can have a bunch of default processes, a bunch of CRT, and an application can call the Windows API to create its own heap (using the HeapCreate API).

When the process is created, the OS will create a new heap for it called the "Default Process Heap", which is actually rarely used in most cases. When we call new / delete and malloc / free, we actually use a bunch of CRT.

Windows , / . , , .

C/++. , Windows.

+3

: , . , stack - IE, , .

, .

(), , "" .

AppDomains , , , .

+1

" AppDomains , , , ".

, , , DLL , .

DLL .

- , , - , DLL .

This behavior has been observed on the 32-bit XP SP3 platform running on .NET 2, and it would be great that individual AppDomains use the same process heap.

If this is not the experience of other people, I would really like to know how to isolate my applications from poisonous DLLs

+1
source

Source: https://habr.com/ru/post/1735164/


All Articles