Memory-Usage.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- This file documents the BFD library.
  4. Copyright (C) 1991-2017 Free Software Foundation, Inc.
  5. Permission is granted to copy, distribute and/or modify this document
  6. under the terms of the GNU Free Documentation License, Version 1.3 or
  7. any later version published by the Free Software Foundation; with the
  8. Invariant Sections being "GNU General Public License" and "Funding
  9. Free Software", the Front-Cover texts being (a) (see below), and with
  10. the Back-Cover Texts being (b) (see below). A copy of the license is
  11. included in the section entitled "GNU Free Documentation License".
  12. (a) The FSF's Front-Cover Text is:
  13. A GNU Manual
  14. (b) The FSF's Back-Cover Text is:
  15. You have freedom to copy and modify this GNU Manual, like GNU
  16. software. Copies published by the Free Software Foundation raise
  17. funds for GNU development. -->
  18. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  19. <head>
  20. <title>Untitled Document: Memory Usage</title>
  21. <meta name="description" content="Untitled Document: Memory Usage">
  22. <meta name="keywords" content="Untitled Document: Memory Usage">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  27. <link href="index.html#Top" rel="start" title="Top">
  28. <link href="BFD-Index.html#BFD-Index" rel="index" title="BFD Index">
  29. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  30. <link href="BFD-front-end.html#BFD-front-end" rel="up" title="BFD front end">
  31. <link href="Initialization.html#Initialization" rel="next" title="Initialization">
  32. <link href="Miscellaneous.html#Miscellaneous" rel="prev" title="Miscellaneous">
  33. <style type="text/css">
  34. <!--
  35. a.summary-letter {text-decoration: none}
  36. blockquote.smallquotation {font-size: smaller}
  37. div.display {margin-left: 3.2em}
  38. div.example {margin-left: 3.2em}
  39. div.indentedblock {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  43. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  44. div.smalllisp {margin-left: 3.2em}
  45. kbd {font-style:oblique}
  46. pre.display {font-family: inherit}
  47. pre.format {font-family: inherit}
  48. pre.menu-comment {font-family: serif}
  49. pre.menu-preformatted {font-family: serif}
  50. pre.smalldisplay {font-family: inherit; font-size: smaller}
  51. pre.smallexample {font-size: smaller}
  52. pre.smallformat {font-family: inherit; font-size: smaller}
  53. pre.smalllisp {font-size: smaller}
  54. span.nocodebreak {white-space:nowrap}
  55. span.nolinebreak {white-space:nowrap}
  56. span.roman {font-family:serif; font-weight:normal}
  57. span.sansserif {font-family:sans-serif; font-weight:normal}
  58. ul.no-bullet {list-style: none}
  59. -->
  60. </style>
  61. </head>
  62. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  63. <a name="Memory-Usage"></a>
  64. <div class="header">
  65. <p>
  66. Next: <a href="Initialization.html#Initialization" accesskey="n" rel="next">Initialization</a>, Previous: <a href="Miscellaneous.html#Miscellaneous" accesskey="p" rel="prev">Miscellaneous</a>, Up: <a href="BFD-front-end.html#BFD-front-end" accesskey="u" rel="up">BFD front end</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="BFD-Index.html#BFD-Index" title="Index" rel="index">Index</a>]</p>
  67. </div>
  68. <hr>
  69. <a name="Memory-Usage-1"></a>
  70. <h3 class="section">2.4 Memory Usage</h3>
  71. <p>BFD keeps all of its internal structures in obstacks. There is one obstack
  72. per open BFD file, into which the current state is stored. When a BFD is
  73. closed, the obstack is deleted, and so everything which has been
  74. allocated by BFD for the closing file is thrown away.
  75. </p>
  76. <p>BFD does not free anything created by an application, but pointers into
  77. <code>bfd</code> structures become invalid on a <code>bfd_close</code>; for example,
  78. after a <code>bfd_close</code> the vector passed to
  79. <code>bfd_canonicalize_symtab</code> is still around, since it has been
  80. allocated by the application, but the data that it pointed to are
  81. lost.
  82. </p>
  83. <p>The general rule is to not close a BFD until all operations dependent
  84. upon data from the BFD have been completed, or all the data from within
  85. the file has been copied. To help with the management of memory, there
  86. is a function (<code>bfd_alloc_size</code>) which returns the number of bytes
  87. in obstacks associated with the supplied BFD. This could be used to
  88. select the greediest open BFD, close it to reclaim the memory, perform
  89. some operation and reopen the BFD again, to get a fresh copy of the data
  90. structures.
  91. </p>
  92. </body>
  93. </html>