public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Re: ld-auto-import memory bug fixing
@ 2001-09-07 13:10 Ralf Habacker
  2001-09-07 14:51 ` Christopher Faylor
  0 siblings, 1 reply; 5+ messages in thread
From: Ralf Habacker @ 2001-09-07 13:10 UTC (permalink / raw)
  To: Binutils; +Cc: Cygwin-Apps

Hi,

is there any way to get the size of by malloc allocated byte of an application ?
If have tried malloc_stats() and mallinfo(), which is described in
/usr/include/malloc.h
and implemented in dlmalloc.cc of the cygwin source, but they seems to be not
defined
in the cygwin1.dll import library.

Another library mmalloc contains mmstats() and mmtrace() which looks equal
malloc_stats() but using
this prints nothing. :-(

Can I use the mmalloc lib with ld to archieve this or is there any other way for
this ?

Ralf

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: ld-auto-import memory bug fixing
  2001-09-07 13:10 ld-auto-import memory bug fixing Ralf Habacker
@ 2001-09-07 14:51 ` Christopher Faylor
  2001-09-12  4:36   ` [PATCH]: " Ralf Habacker
  0 siblings, 1 reply; 5+ messages in thread
From: Christopher Faylor @ 2001-09-07 14:51 UTC (permalink / raw)
  To: Binutils; +Cc: cygwin-apps

On Fri, Sep 07, 2001 at 10:14:04PM +0200, Ralf Habacker wrote:
>Hi,
>
>is there any way to get the size of by malloc allocated byte of an application ?
>If have tried malloc_stats() and mallinfo(), which is described in
>/usr/include/malloc.h
>and implemented in dlmalloc.cc of the cygwin source, but they seems to be not
>defined
>in the cygwin1.dll import library.

dlmalloc is the debugging malloc library that cygwin uses when compiled
with malloc debugging (configure --enable-malloc-debugging).

The normal malloc comes from newlib.

>Another library mmalloc contains mmstats() and mmtrace() which looks equal
>malloc_stats() but using
>this prints nothing. :-(

I don't think that anything in binutils uses mmalloc.

cgf

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH]: ld-auto-import memory bug fixing
  2001-09-07 14:51 ` Christopher Faylor
@ 2001-09-12  4:36   ` Ralf Habacker
  2001-09-14  7:22     ` Nick Clifton
  0 siblings, 1 reply; 5+ messages in thread
From: Ralf Habacker @ 2001-09-12  4:36 UTC (permalink / raw)
  To: Binutils

[-- Attachment #1: Type: text/plain, Size: 488 bytes --]

Hi,

this is a short patch for the ld auto-import memory bug.

I have tested it while compiling kde2 with about 20 dll's without any bugs. It
reduces memory using about 150 MB for a lib with many
dependencies like kdelibs/kdeui.

Please note as told in previous mail in this tread, that there are some more
ocurrence of this behaviour and that there might be potential to reduce memory
consumption.

I like to ask again: Is there only one symbol table for a bfd object ?

Regards

Ralf



[-- Attachment #2: ld-memory-leak-fix.patch --]
[-- Type: text/x-diff, Size: 1296 bytes --]

$ cvs -z7 dif -ubB pe-dll.c
Index: pe-dll.c
===================================================================
RCS file: /cvs/src/src/ld/pe-dll.c,v
retrieving revision 1.26
diff -u -b -B -r1.26 pe-dll.c
--- pe-dll.c    2001/08/21 11:42:57     1.26
+++ pe-dll.c    2001/09/12 11:19:59
@@ -989,13 +989,18 @@

   for (b = info->input_bfds; b; b = b->link_next)
     {
-      arelent **relocs;
-      int relsize, nrelocs, i;
+      asymbol **symbols;
+      int nsyms, symsize;

+      symsize = bfd_get_symtab_upper_bound (b);
+      symbols = (asymbol **) xmalloc (symsize);
+      nsyms = bfd_canonicalize_symtab (b, symbols);
+
       for (s = b->sections; s; s = s->next)
        {
-         asymbol **symbols;
-         int nsyms, symsize;
+    arelent **relocs;
+    int relsize, nrelocs, i;
+
          int flags = bfd_get_section_flags (b, s);

          /* Skip discarded linkonce sections */
@@ -1005,10 +1010,6 @@

          current_sec=s;

-         symsize = bfd_get_symtab_upper_bound (b);
-         symbols = (asymbol **) xmalloc (symsize);
-         nsyms = bfd_canonicalize_symtab (b, symbols);
-
          relsize = bfd_get_reloc_upper_bound (b, s);
          relocs = (arelent **) xmalloc ((size_t) relsize);
          nrelocs = bfd_canonicalize_reloc (b, s, relocs, symbols);


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH]: ld-auto-import memory bug fixing
  2001-09-12  4:36   ` [PATCH]: " Ralf Habacker
@ 2001-09-14  7:22     ` Nick Clifton
  2001-09-15  9:44       ` Ralf Habacker
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Clifton @ 2001-09-14  7:22 UTC (permalink / raw)
  To: Ralf Habacker; +Cc: Binutils

Hi Ralf,

> this is a short patch for the ld auto-import memory bug.

Thanks.  I have approved and applied this patch to the current CVS
sources.

> I like to ask again: Is there only one symbol table for a bfd object ?

Sorry for the delay in replying.  I believe that the answer is yes
and no.  Some bfd objects can have two symbol tables.  ELF BFD objects
for example can have an ordinary symbol table and a dynamic symbol
table.  I think however that COFF and PE BFD objects only have one
symbol table.

Cheers
        Nick

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH]: ld-auto-import memory bug fixing
  2001-09-14  7:22     ` Nick Clifton
@ 2001-09-15  9:44       ` Ralf Habacker
  0 siblings, 0 replies; 5+ messages in thread
From: Ralf Habacker @ 2001-09-15  9:44 UTC (permalink / raw)
  To: Binutils

> Hi Ralf,			
> 
> > this is a short patch for the ld auto-import memory bug.
> 
> Thanks.  I have approved and applied this patch to the current CVS
> sources.
> 
> > I like to ask again: Is there only one symbol table for a bfd object ?
> 
> Sorry for the delay in replying.  I believe that the answer is yes
> and no.  Some bfd objects can have two symbol tables.  ELF BFD objects
> for example can have an ordinary symbol table and a dynamic symbol
> table.  I think however that COFF and PE BFD objects only have one
> symbol table.
> 
I'm going on with the regular ld-auto-import memory bug fixing thread. 

> Cheers
>         Nick
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-09-15  9:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-07 13:10 ld-auto-import memory bug fixing Ralf Habacker
2001-09-07 14:51 ` Christopher Faylor
2001-09-12  4:36   ` [PATCH]: " Ralf Habacker
2001-09-14  7:22     ` Nick Clifton
2001-09-15  9:44       ` Ralf Habacker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).