NPN_MemFlush

  • Revision slug: NPN_MemFlush
  • Revision title: NPN_MemFlush
  • Revision id: 91499
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment copy edit; 17 words added, 8 words removed

Revision Content

{{ Np-plugin-api() }}

Summary

Note: This function is only implemented on Mac OS X.

Requests that the browser free a specified amount of memory.

Syntax

#include <npapi.h>
 
uint32 NPN_MemFlush(uint32 size);

Parameters

The function has the following parameters:

size
Size of memory, in bytes, to free in the browser's memory space.

Returns

  • If successful, the function returns the amount of freed memory, in bytes.
  • If no memory can be freed, the browser returns 0.

Description

The plug-in calls NPN_MemFlush() when it is not possible to call NPN_MemAlloc(), for example, when calling system APIs that indirectly allocate memory. To request that the browser free as much memory as possible, call NPN_MemFlush() repeatedly until it returns 0.

On the Mac, you can use this method to free memory before calling memory-intensive system calls.

In general, plug-ins should use NPN_MemAlloc() to allocate memory in the browser's memory space, since this function automatically frees cached data if necessary to fulfill the request.

See Also

NPN_MemFree()

Revision Source

<p>{{ Np-plugin-api() }}</p>
<h3 name="Summary">Summary</h3>
<div class="note"><strong>Note:</strong> This function is only implemented on Mac OS X.</div>
<p>Requests that the browser free a specified amount of memory.</p>
<h3 name="Syntax">Syntax</h3>
<pre>#include &lt;npapi.h&gt;
 
uint32 NPN_MemFlush(uint32 size);
</pre>
<h3 name="Parameters">Parameters</h3>
<p>The function has the following parameters:</p>
<dl> <dt><code>size</code></dt> <dd>Size of memory, in bytes, to free in the browser's memory space.</dd>
</dl>
<h3 name="Returns">Returns</h3>
<ul> <li>If successful, the function returns the amount of freed memory, in bytes.</li> <li>If no memory can be freed, the browser returns 0.</li>
</ul>
<h3 name="Description">Description</h3>
<p>The plug-in calls <code>NPN_MemFlush()</code> when it is not possible to call <a href="/en/NPN_MemAlloc" title="en/NPN_MemAlloc">NPN_MemAlloc()</a>, for example, when calling system APIs that indirectly allocate memory. To request that the browser free as much memory as possible, call <code>NPN_MemFlush()</code> repeatedly until it returns 0.</p>
<p>On the Mac, you can use this method to free memory before calling memory-intensive system calls.</p>
<p>In general, plug-ins should use <a href="/en/NPN_MemAlloc" title="en/NPN_MemAlloc">NPN_MemAlloc()</a> to allocate memory in the browser's memory space, since this function automatically frees cached data if necessary to fulfill the request.</p>
<h3 name="See_Also">See Also</h3>
<p><a href="/en/NPN_MemFree" title="en/NPN_MemFree">NPN_MemFree()</a></p>
Revert to this revision