|
AVPKit
|
This class's implementation of malloc() and free() will forward to the standard library's malloc() and free(), UNLESS you're running in a JVM, in which case it will use Java to manage the memory for us. More...
#include <JNIMemoryManager.h>
Static Public Member Functions | |
| static void * | malloc (size_t requested_size) |
| Create a malloced block of AT LEAST site_t bounds long. More... | |
| static void | free (void *mem) |
| Free memory previously allocated by malloc(void*, size_t). More... | |
| static void * | malloc (void *allocator, size_t requested_size) |
| Create a malloced block of AT LEAST site_t bounds long by using an allocator. More... | |
This class's implementation of malloc() and free() will forward to the standard library's malloc() and free(), UNLESS you're running in a JVM, in which case it will use Java to manage the memory for us.
Use it when you have large memory structures that live for a long time that you want the JVM to resource manage for you, or if you're trying to track down an object in Java that is collecting large objects; this will allow you to tie back big chunks of memory to the misbehaving java object in your code (using a memory profiler like SAP's Eclipse plugin).
Definition at line 49 of file JNIMemoryManager.h.
|
static |
Free memory previously allocated by malloc(void*, size_t).
| mem | previously allocated by malloc(void*, size_t) |
Definition at line 102 of file JNIMemoryManager.cpp.
|
static |
Create a malloced block of AT LEAST site_t bounds long.
This block will be aligned on a 128-bit boundary, suitable for passing to libraries that do SSE-based operations on it.
| requested_size | Requested minimum size of memory, in bytes |
| std::std_alloc | If memory cannot be allocated |
Definition at line 89 of file JNIMemoryManager.cpp.
|
static |
Create a malloced block of AT LEAST site_t bounds long by using an allocator.
Allocates a block of memory using the passed in allocator. If running inside a JVM, allocator must be a jobject, and must be a subclass of com.avpkit.ferry.JNIMemoryManager. Also you must ensure that allocator lives longer than the block of memory you allocate (i.e. does not get collected by the GC).
This method is useful for Swig proxy objects where you want to fake a reference from the proxy object to memory allocated by the object the proxy objet mallocs. Then, when checked using profiling tools, the native memory will accumulate to the proxy object, which will help you find proxy leaks.
If you are not allocating with the JVM, or we are using JVM Direct Buffers for memory, the allocator object is only used to help print debugging messages.
This block will be aligned on a 128-bit boundary, suitable for passing to libraries that do SSE-based operations on it.
Lastly if you understood or followed any of the above comments you're not drunk enough to work on this code.
| requested_size | Requested minimum size of memory, in bytes |
| allocator | Either a jobject as documented above, or 0. |
| std::std_alloc | If memory cannot be allocated |
Definition at line 95 of file JNIMemoryManager.cpp.