| 1 |
|
| 2 |
<HTML> |
| 3 |
<HEAD> |
| 4 |
<TITLE>Out of Memory</TITLE> |
| 5 |
</HEAD> |
| 6 |
<BODY> |
| 7 |
|
| 8 |
|
| 9 |
<H2><A NAME="xpaoom">Xpaoom: What happens when XPA runs out of memory?</A></H2> |
| 10 |
|
| 11 |
|
| 12 |
<H2>Summary</H2> |
| 13 |
<P> |
| 14 |
When XPA can't allocate memory, it exits. You can arrange to have it call |
| 15 |
longjmp() instead. |
| 16 |
|
| 17 |
|
| 18 |
<H2>Description</H2> |
| 19 |
<P> |
| 20 |
When an XPA server or client cannot allocate memory, it will attempt to |
| 21 |
output an error message and then exit. If this is not satisfactory (e.g., |
| 22 |
perhaps your program is interactive and can recover from OOM errors), you |
| 23 |
can tell XPA to call longjmp() to go to a recovery branch. To pass the |
| 24 |
requisite jmp_buf variable to XPA, make the following call: |
| 25 |
<PRE> |
| 26 |
XPASaveJmp(void *env); |
| 27 |
</PRE> |
| 28 |
The value of env is the address of a jmp_buf variable that was previously |
| 29 |
passed to setjmp(). For example: |
| 30 |
<PRE> |
| 31 |
jmp_buf env; |
| 32 |
... |
| 33 |
if( setjmp(jmp_buf) != 0 ){ |
| 34 |
/* out of memory -- take corrective action, if possible */ |
| 35 |
} else { |
| 36 |
/* save env for XPA */ |
| 37 |
XPASaveJmp((void *)&jmp_buf); |
| 38 |
} |
| 39 |
// enter main loop ... |
| 40 |
</PRE> |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
<P> |
| 47 |
<A HREF="./help.html">Go to XPA Help Index</A> |
| 48 |
|
| 49 |
<H5>Last updated: April 7, 2009</H5> |
| 50 |
</BODY> |
| 51 |
</HTML> |
| 52 |
|