[RTEMS Project] #2414: Repeated call to dlopen without dlclose leaks memory.

RTEMS trac trac at rtems.org
Thu Sep 10 08:35:10 UTC 2015


#2414: Repeated call to dlopen without dlclose leaks memory.
---------------------+--------------------
 Reporter:  ppisa    |      Owner:
     Type:  defect   |     Status:  new
 Priority:  normal   |  Milestone:  4.11.1
Component:  General  |    Version:  4.11
 Severity:  normal   |   Keywords:  dlopen
---------------------+--------------------
 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

 http://rtime.felk.cvut.cz/gitweb/rtems-devel.git/blob/refs/heads/master
 :/rtems-omk-template/appdl/init.c#l109

 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.

--
Ticket URL: <http://devel.rtems.org/ticket/2414>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list