Thoughts on memory usage of Linux Dynamic Link Library
Source: Internet
Author: User
Thoughts on memory usage of Linux dynamic link library-general Linux technology-Linux programming and kernel information. The following is a detailed description. When writing a program, we call it in the main program to facilitate writing many so files.
We know that there are two methods to call the dynamic link library. One is to dynamically compile the dynamic link library during compilation; one is to use dlopen to call the dynamic connection library during execution. What are the differences between the two types?
1. After the dynamic link library is compiled during compilation, the dependency of the dynamic link library is left in the elf File. When a program is started, linux only allocates a linear space for it, but does not allocate specific memory. When it is used, it allocates physical memory.
But this has encountered a problem. If our main program calls a database once, the system allocates a physical address for it, and then we no longer need the dynamic link library, how to recycle allocated physical addresses. Can I only wait until the program exits?
This is indeed the case I found.
2. You can solve this problem by using dlopen. After the dynamic link library is not needed, you can unmount the dynamic link library explicitly.
In this way, the problem is that programmers are troublesome to write programs.
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