Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 56882686c7ad11f4bd595dacb1f22fe7 > files > 123

hoard-3.7.1-1mdv2009.1.i586.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
<document> 
  <header> 
    <title>Using Hoard</title> 
  </header>

<body>

<p>
Using Hoard is easy. On UNIX-based platforms, all you have to do is set one environment variable. You do not need to change any source code, recompile or relink your application. On Windows, you actually have even greater flexibility.
</p>


<section>
  <title>UNIX</title>
  <p>
In UNIX, you can use the LD_PRELOAD variable to use
Hoard instead of the system allocator for any program not linked with
the "static option" (that's most programs). Below are settings for
Linux and Solaris.
  </p>
  <section>
    <title>Linux</title>
    <source>
LD_PRELOAD="/path/libhoard.so:/usr/lib/libdl.so"
    </source>
  </section>
  <section>
    <title>Solaris</title>
    <p>
    Depending on whether you are using the GNU-compiled version (as
    produced by compile) or the Sun
    Workshop-compiled versions (produced by
    compile-sunw), your settings will be slightly
    different.
    </p>

    <table>
        <tr>
              <td>Version</td>
              <td>Setting</td>
        </tr>
        <tr>
              <td>GNU</td>
              <td>
                <source>
LD_PRELOAD="/path/libhoard.so:/usr/lib/libdl.so"
                </source>
              </td>
           </tr>
           <tr>
              <td>Sun (<em>32-bits</em>)</td>
              <td>
                 <source>
LD_PRELOAD="/path/libhoard_32.so:/usr/lib/libCrun.so.1:/usr/lib/libdl.so"
                  </source>
              </td>
           </tr>
           <tr>
              <td>Sun (<em>64-bits</em>)</td>
              <td>
                 <source>
LD_PRELOAD="/path/libhoard_64.so:/usr/lib/64/libCrun.so.1:/usr/lib/64/libdl.so"
                  </source>
              </td>
           </tr>
     </table>

       <p>
For some security-sensitive applications, Solaris requires you place
libraries used in LD_PRELOAD into the /usr/lib/secure directory. In that event,
after copying these libraries into /usr/lib/secure, set
LD_PRELOAD by omitting the absolute locations of the libraries, as follows:
       </p>
       <source>
LD_PRELOAD="libhoard.so:libCrun.so.1:libdl.so"
       </source>

</section>
</section>

<section>
  <title>Windows</title>
  <p>
  There are two ways to use Hoard on Windows.
  </p>
  <ol>
  <li>
    Using winhoard
    <p>
The first and best method is to use winhoard. Winhoard replaces
malloc/new calls from your program and any DLLs it might use (leaving
HeapAlloc calls intact).
</p>

<p>
To use the Winhoard version, link your executable with
usewinhoard.obj and
winhoard.lib, and then use
winhoard.dll:
</p>

<source>
cl /Ox /MD myprogram.cpp usewinhoard.obj winhoard.lib
</source>

  </li>
  <li>
    Using libhoard
    <p>

The other method is to link directly with the libhoard DLL. This
approach is simple, but only suitable for small applications, since it
will not affect malloc calls in any other DLL you might load. To use
this option, you should put the following into your source code as the
very first lines:
</p>

<source>
#if defined(USE_HOARD)
#pragma comment(lib, "libhoard.lib") 
#endif 
</source>

<p>
This stanza should be in the first part of a header file included by
all of your code. It ensures that Hoard loads before any other library
(you will need libhoard.lib in your path). When
you execute your program, as long as libhoard.dll
is in your path, your program will run with Hoard instead of the
system allocator. Note that you must compile your program with the
/MD flag, as in:
</p>

<source>
cl /MD /G6 /Ox /DUSE_HOARD=1 myprogram.cpp 
</source>

<p>
Hoard will not work if you use another switch (like
/MT) to compile your program.
    </p>
  </li>
  </ol>
</section>



</body>

</document>