1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
---|
2 | <html> |
---|
3 | <head> |
---|
4 | <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
---|
5 | <meta content="Apache Forrest" name="Generator"> |
---|
6 | <meta name="Forrest-version" content="0.6"> |
---|
7 | <meta name="Forrest-skin-name" content="pelt"> |
---|
8 | <title>Using Hoard</title> |
---|
9 | <link type="text/css" href="skin/basic.css" rel="stylesheet"> |
---|
10 | <link media="screen" type="text/css" href="skin/screen.css" rel="stylesheet"> |
---|
11 | <link media="print" type="text/css" href="skin/print.css" rel="stylesheet"> |
---|
12 | <link type="text/css" href="skin/profile.css" rel="stylesheet"> |
---|
13 | <script src="skin/getBlank.js" language="javascript" type="text/javascript"></script><script src="skin/getMenu.js" language="javascript" type="text/javascript"></script><script src="skin/fontsize.js" language="javascript" type="text/javascript"></script> |
---|
14 | <link rel="shortcut icon" href=""> |
---|
15 | </head> |
---|
16 | <body onload="init()"> |
---|
17 | <script type="text/javascript">ndeSetTextSize();</script> |
---|
18 | <div id="top"> |
---|
19 | <!--+ |
---|
20 | |header |
---|
21 | +--> |
---|
22 | <div class="header"> |
---|
23 | <!--+ |
---|
24 | |start group logo |
---|
25 | +--> |
---|
26 | <div class="grouplogo"> |
---|
27 | <a href="http://www.hoard.org"><img class="logoImage" alt="Hoard" src="images/hoard-logo.jpg" title="The Hoard Multiprocessor Memory Allocator"></a> |
---|
28 | </div> |
---|
29 | <!--+ |
---|
30 | |end group logo |
---|
31 | +--> |
---|
32 | <!--+ |
---|
33 | |start Project Logo |
---|
34 | +--> |
---|
35 | <div class="projectlogoA1"> |
---|
36 | <a href=""></a> |
---|
37 | </div> |
---|
38 | <!--+ |
---|
39 | |end Project Logo |
---|
40 | +--> |
---|
41 | <!--+ |
---|
42 | |start Tabs |
---|
43 | +--> |
---|
44 | <ul id="tabs"></ul> |
---|
45 | <!--+ |
---|
46 | |end Tabs |
---|
47 | +--> |
---|
48 | </div> |
---|
49 | </div> |
---|
50 | <div id="main"> |
---|
51 | <div id="publishedStrip"> |
---|
52 | <!--+ |
---|
53 | |start Subtabs |
---|
54 | +--> |
---|
55 | <div id="level2tabs"></div> |
---|
56 | <!--+ |
---|
57 | |end Endtabs |
---|
58 | +--> |
---|
59 | <script type="text/javascript" language="JavaScript"><!-- |
---|
60 | document.write("Published: " + document.lastModified); |
---|
61 | // --></script> |
---|
62 | </div> |
---|
63 | <!--+ |
---|
64 | |breadtrail |
---|
65 | +--> |
---|
66 | <div class="breadtrail"> |
---|
67 | |
---|
68 | |
---|
69 | </div> |
---|
70 | <!--+ |
---|
71 | |start Menu, mainarea |
---|
72 | +--> |
---|
73 | <!--+ |
---|
74 | |start Menu |
---|
75 | +--> |
---|
76 | <div id="menu"> |
---|
77 | <div onclick="SwitchMenu('menu_selected_1.1', 'skin/')" id="menu_selected_1.1Title" class="menutitle" style="background-image: url('skin/images/chapter_open.gif');">Table of Contents</div> |
---|
78 | <div id="menu_selected_1.1" class="selectedmenuitemgroup" style="display: block;"> |
---|
79 | <div class="menuitem"> |
---|
80 | <a title="Welcome to Hoard" href="index.html">Home</a> |
---|
81 | </div> |
---|
82 | <div class="menuitem"> |
---|
83 | <a title="Download Hoard" href="download.html">Download</a> |
---|
84 | </div> |
---|
85 | <div class="menuitem"> |
---|
86 | <a title="Screenshots" href="screenshot.html">Screenshots</a> |
---|
87 | </div> |
---|
88 | <div class="menupage"> |
---|
89 | <div class="menupagetitle">Using Hoard</div> |
---|
90 | </div> |
---|
91 | <div class="menuitem"> |
---|
92 | <a title="How to Build Hoard" href="building.html">Building Hoard</a> |
---|
93 | </div> |
---|
94 | <div class="menuitem"> |
---|
95 | <a title="FAQs" href="faqs.html">FAQs</a> |
---|
96 | </div> |
---|
97 | <div class="menuitem"> |
---|
98 | <a title="License Info" href="licensing.html">Licensing Info</a> |
---|
99 | </div> |
---|
100 | </div> |
---|
101 | <div id="credit"></div> |
---|
102 | <div id="roundbottom"> |
---|
103 | <img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div> |
---|
104 | <!--+ |
---|
105 | |alternative credits |
---|
106 | +--> |
---|
107 | </div> |
---|
108 | <!--+ |
---|
109 | |end Menu |
---|
110 | +--> |
---|
111 | <!--+ |
---|
112 | |start content |
---|
113 | +--> |
---|
114 | <div id="content"> |
---|
115 | <div id="skinconf-txtlink"></div> |
---|
116 | <h1>Using Hoard</h1> |
---|
117 | <div id="minitoc-area"> |
---|
118 | <ul class="minitoc"> |
---|
119 | <li> |
---|
120 | <a href="#UNIX">UNIX</a> |
---|
121 | <ul class="minitoc"> |
---|
122 | <li> |
---|
123 | <a href="#Linux">Linux</a> |
---|
124 | </li> |
---|
125 | <li> |
---|
126 | <a href="#Solaris">Solaris</a> |
---|
127 | </li> |
---|
128 | </ul> |
---|
129 | </li> |
---|
130 | <li> |
---|
131 | <a href="#Windows">Windows</a> |
---|
132 | </li> |
---|
133 | </ul> |
---|
134 | </div> |
---|
135 | |
---|
136 | |
---|
137 | <p> |
---|
138 | 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. |
---|
139 | </p> |
---|
140 | |
---|
141 | |
---|
142 | |
---|
143 | <a name="N1000F"></a><a name="UNIX"></a> |
---|
144 | <h2 class="boxed">UNIX</h2> |
---|
145 | <div class="section"> |
---|
146 | <p> |
---|
147 | In UNIX, you can use the LD_PRELOAD variable to use |
---|
148 | Hoard instead of the system allocator for any program not linked with |
---|
149 | the "static option" (that's most programs). Below are settings for |
---|
150 | Linux and Solaris. |
---|
151 | </p> |
---|
152 | <a name="N10018"></a><a name="Linux"></a> |
---|
153 | <h3 class="boxed">Linux</h3> |
---|
154 | <pre class="code"> |
---|
155 | LD_PRELOAD="/path/libhoard.so" |
---|
156 | </pre> |
---|
157 | <a name="N10023"></a><a name="Solaris"></a> |
---|
158 | <h3 class="boxed">Solaris</h3> |
---|
159 | <p> |
---|
160 | Depending on whether you are using the GNU-compiled version (as |
---|
161 | produced by compile) or the Sun |
---|
162 | Workshop-compiled versions (produced by |
---|
163 | compile-sunw), your settings will be slightly |
---|
164 | different. |
---|
165 | </p> |
---|
166 | <table class="ForrestTable" cellspacing="1" cellpadding="4"> |
---|
167 | |
---|
168 | <tr> |
---|
169 | |
---|
170 | <td colspan="1" rowspan="1">Version</td> |
---|
171 | <td colspan="1" rowspan="1">Setting</td> |
---|
172 | |
---|
173 | </tr> |
---|
174 | |
---|
175 | <tr> |
---|
176 | |
---|
177 | <td colspan="1" rowspan="1">GNU</td> |
---|
178 | <td colspan="1" rowspan="1"> |
---|
179 | |
---|
180 | <pre class="code"> |
---|
181 | LD_PRELOAD="/path/libhoard.so" |
---|
182 | </pre> |
---|
183 | |
---|
184 | </td> |
---|
185 | |
---|
186 | </tr> |
---|
187 | |
---|
188 | <tr> |
---|
189 | |
---|
190 | <td colspan="1" rowspan="1">Sun (<em>32-bits</em>)</td> |
---|
191 | <td colspan="1" rowspan="1"> |
---|
192 | |
---|
193 | <pre class="code"> |
---|
194 | LD_PRELOAD="/path/libhoard_32.so:/usr/lib/libCrun.so.1" |
---|
195 | </pre> |
---|
196 | |
---|
197 | </td> |
---|
198 | |
---|
199 | </tr> |
---|
200 | |
---|
201 | <tr> |
---|
202 | |
---|
203 | <td colspan="1" rowspan="1">Sun (<em>64-bits</em>)</td> |
---|
204 | <td colspan="1" rowspan="1"> |
---|
205 | |
---|
206 | <pre class="code"> |
---|
207 | LD_PRELOAD="/path/libhoard_64.so:/usr/lib/64/libCrun.so.1" |
---|
208 | </pre> |
---|
209 | |
---|
210 | </td> |
---|
211 | |
---|
212 | </tr> |
---|
213 | |
---|
214 | </table> |
---|
215 | <p> |
---|
216 | For some security-sensitive applications, Solaris requires you place |
---|
217 | libraries used in LD_PRELOAD into the /usr/lib/secure directory. In that event, |
---|
218 | after copying these libraries into /usr/lib/secure, set |
---|
219 | LD_PRELOAD by omitting the absolute locations of the libraries, as follows: |
---|
220 | </p> |
---|
221 | <pre class="code"> |
---|
222 | LD_PRELOAD="libhoard.so:libCrun.so.1" |
---|
223 | </pre> |
---|
224 | </div> |
---|
225 | |
---|
226 | |
---|
227 | <a name="N1007E"></a><a name="Windows"></a> |
---|
228 | <h2 class="boxed">Windows</h2> |
---|
229 | <div class="section"> |
---|
230 | <p> |
---|
231 | There are two ways to use Hoard on Windows. |
---|
232 | </p> |
---|
233 | <ol> |
---|
234 | |
---|
235 | <li> |
---|
236 | Using winhoard |
---|
237 | <p> |
---|
238 | The first and best method is to use winhoard. Winhoard replaces |
---|
239 | malloc/new calls from your program and any DLLs it might use (leaving |
---|
240 | HeapAlloc calls intact). |
---|
241 | </p> |
---|
242 | |
---|
243 | |
---|
244 | <p> |
---|
245 | To use the Winhoard version, link your executable with |
---|
246 | usewinhoard.obj and |
---|
247 | winhoard.lib, and then use |
---|
248 | winhoard.dll: |
---|
249 | </p> |
---|
250 | |
---|
251 | |
---|
252 | <pre class="code"> |
---|
253 | cl /Ox /MD myprogram.cpp usewinhoard.obj winhoard.lib |
---|
254 | </pre> |
---|
255 | |
---|
256 | |
---|
257 | </li> |
---|
258 | |
---|
259 | <li> |
---|
260 | Using libhoard |
---|
261 | <p> |
---|
262 | |
---|
263 | The other method is to link directly with the libhoard DLL. This |
---|
264 | approach is simple, but only suitable for small applications, since it |
---|
265 | will not affect malloc calls in any other DLL you might load. To use |
---|
266 | this option, you should put the following into your source code as the |
---|
267 | very first lines: |
---|
268 | </p> |
---|
269 | |
---|
270 | |
---|
271 | <pre class="code"> |
---|
272 | #if defined(USE_HOARD) |
---|
273 | #pragma comment(lib, "libhoard.lib") |
---|
274 | #endif |
---|
275 | </pre> |
---|
276 | |
---|
277 | |
---|
278 | <p> |
---|
279 | This stanza should be in the first part of a header file included by |
---|
280 | all of your code. It ensures that Hoard loads before any other library |
---|
281 | (you will need libhoard.lib in your path). When |
---|
282 | you execute your program, as long as libhoard.dll |
---|
283 | is in your path, your program will run with Hoard instead of the |
---|
284 | system allocator. Note that you must compile your program with the |
---|
285 | /MD flag, as in: |
---|
286 | </p> |
---|
287 | |
---|
288 | |
---|
289 | <pre class="code"> |
---|
290 | cl /MD /G6 /Ox /DUSE_HOARD=1 myprogram.cpp |
---|
291 | </pre> |
---|
292 | |
---|
293 | |
---|
294 | <p> |
---|
295 | Hoard will not work if you use another switch (like |
---|
296 | /MT) to compile your program. |
---|
297 | </p> |
---|
298 | |
---|
299 | </li> |
---|
300 | |
---|
301 | </ol> |
---|
302 | </div> |
---|
303 | |
---|
304 | |
---|
305 | |
---|
306 | |
---|
307 | </div> |
---|
308 | <!--+ |
---|
309 | |end content |
---|
310 | +--> |
---|
311 | <div class="clearboth"> </div> |
---|
312 | </div> |
---|
313 | <div id="footer"> |
---|
314 | <!--+ |
---|
315 | |start bottomstrip |
---|
316 | +--> |
---|
317 | <div class="lastmodified"> |
---|
318 | <script type="text/javascript"><!-- |
---|
319 | document.write("Last Published: " + document.lastModified); |
---|
320 | // --></script> |
---|
321 | </div> |
---|
322 | <div class="copyright"> |
---|
323 | Copyright © 2005 Emery Berger.</div> |
---|
324 | <div id="feedback"> |
---|
325 | Send feedback about the website to: |
---|
326 | <a id="feedbackto" href="mailto:emery@cs.umass.edu?subject=Feedback,using.html">emery@cs.umass.edu</a> |
---|
327 | </div> |
---|
328 | <!--+ |
---|
329 | |end bottomstrip |
---|
330 | +--> |
---|
331 | </div> |
---|
332 | </body> |
---|
333 | </html> |
---|