Function gdal_sys::CPLVirtualMemNew [] [src]

pub unsafe extern "C" fn CPLVirtualMemNew(
    nSize: usize,
    nCacheSize: usize,
    nPageSizeHint: usize,
    bSingleThreadUsage: c_int,
    eAccessMode: Type,
    pfnCachePage: CPLVirtualMemCachePageCbk,
    pfnUnCachePage: CPLVirtualMemUnCachePageCbk,
    pfnFreeUserData: CPLVirtualMemFreeUserData,
    pCbkUserData: *mut c_void
) -> *mut CPLVirtualMem

Create a new virtual memory mapping.

This will reserve an area of virtual memory of size nSize, whose size might be potentially much larger than the physical memory available. Initially, no physical memory will be allocated. As soon as memory pages will be accessed, they will be allocated transparently and filled with the pfnCachePage callback. When the allowed cache size is reached, the least recently used pages will be unallocated.

On Linux AMD64 platforms, the maximum value for nSize is 128 TB. On Linux x86 platforms, the maximum value for nSize is 2 GB.

Only supported on Linux for now.

Note that on Linux, this function will install a SIGSEGV handler. The original handler will be restored by CPLVirtualMemManagerTerminate().

@param nSize size in bytes of the virtual memory mapping. @param nCacheSize size in bytes of the maximum memory that will be really allocated (must ideally fit into RAM). @param nPageSizeHint hint for the page size. Must be a multiple of the system page size, returned by CPLGetPageSize(). Minimum value is generally 4096. Might be set to 0 to let the function determine a default page size. @param bSingleThreadUsage set to TRUE if there will be no concurrent threads that will access the virtual memory mapping. This can optimize performance a bit. @param eAccessMode permission to use for the virtual memory mapping. @param pfnCachePage callback triggered when a still unmapped page of virtual memory is accessed. The callback has the responsibility of filling the page with relevant values. @param pfnUnCachePage callback triggered when a dirty mapped page is going to be freed (saturation of cache, or termination of the virtual memory mapping). Might be NULL. @param pfnFreeUserData callback that can be used to free pCbkUserData. Might be NULL @param pCbkUserData user data passed to pfnCachePage and pfnUnCachePage.

@return a virtual memory object that must be freed by CPLVirtualMemFree(), or NULL in case of failure.

@since GDAL 2.0