Notice: We have migrated to GitLab launching 2024-05-01 see here:

#2414 assigned defect

Repeated call to dlopen without dlclose leaks memory.

Reported by: Pavel Pisa Owned by: Needs Funding
Priority: normal Milestone: Indefinite
Component: unspecified Version: 4.11
Severity: normal Keywords: dlopen
Cc: Blocked By:


There are use cases where dlopen() and dlsym() are called each time when some program (interpreter) wants to call some function without need to track if given object file/dynamic library has already been loaded.

The object file handle cannot be closed by dlclose() in the case that called function is allowed to start other threads because memory used for dynamically loaded code can be reused for some other data/code in after dlclose(). It even causes unnecessary overhead for subsequent calls to load file again to memory when released previously.

So repeated call to dlopen() for the same file is useful.

According to my tests each subsequent call of of the function dlopen_forshell() in my test code leaks 32 bytes of memory on i386

The memory useage for simple object file containing single function with printf() call

The first dlopen call 65004 bytes. Each subsequent call without dlclose 32 bytes.

Change History (2)

comment:1 Changed on 01/26/17 at 07:16:00 by Sebastian Huber


comment:2 Changed on 02/15/17 at 13:37:51 by Sebastian Huber

Milestone: 4.11.2Indefinite
Owner: set to Needs Funding
Status: newassigned
Note: See TracTickets for help on using tickets.