Why cannot STL parameters be used between windows program modules?

Source: Internet
Author: User

Theoretical Basis:
1. The C ++ Runtime Library for Windows is divided into two types: multi-threaded and multi-threaded DLL. The former is a static library and will be linked to the targetProgramThe latter is a dynamic link library, which is dynamically loaded when the target program is running.

2. Windows heap memory is divided into two types: Default heap and private heap. By default, the heap can be accessed across modules in the same process, while the private heap can only be accessed in the module.

3. The CRT function in the C ++ Runtime library uses the new operator or the malloc function to allocate memory. Both of them call the heapalloc API on the private stack named _ crtheap for memory allocation.

It can be seen that the multi-threaded DLL program can safely pass STL parameters across modules, because all memory allocation is in the DLL module; the multi-threaded program can only pass the memory address on the default stack.

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.