Home Products Contracting Purchase About Contact
Home Products Contracting Purchase About Blog Contact
VMem VMem

Download

You can download and try VMem for free. For commercial usage you must
purchase a license.

Setup

The fastest way to try out VMem is to include VMem.cpp/h into your project, and then globally override new and delete to call the VMem Alloc and Free functions.

void* operator new(size_t size)
{
    return VMem::Alloc(size);
}

void operator delete(void* p)
{
    VMem::Free(p);
}

void* operator new[](size_t size)
{
    return VMem::Alloc(size);
}

void operator delete[](void* p)
{
    VMem::Free(p);
}

Please see the README.txt in the VMem download for detailed instructions on integrating VMem into your codebase.



Changes



25/02/2020Version: 3.7

-renamed .hpp files to .h
-tidied up some Switch platofrm includes
-removed unused file VMemAtomic.h


23/09/2019Version: 3.6

-retargetted projects to VS2017
-renamed VMEM_OS_UNIX to VMEM_OS_LINUX
-dropped MBCS charset support
-enabled SDLCheck compile flag in debug
-only define VMEM_COALESCE_HEAP_MARKER if not already defined
-removed unnecessary const from VMemHashMap::Resize


05/09/2019Version: 3.5

-fixed VMEM_RECORD_ALLOCS for PS4


23/03/2018Version: 3.4

Summary: Checking of allocated memory markers, setting of unused memory in FSA pages, fixed recursive locks on PS4/Unix

-checking of allocated memory markers (debug level 3)
-always enable FSA page header markers in x64 (in x64 we have a spare 4 bytes due to padding)
-FSA allocations are now cleared to freed memory up to the entire slot size
-added guards to the end of FSA pages
-fixed recursive locking in the protected heap and coalesce heap integrity checking.
-reduced FSAPageHeader size by 8 bytes
-tidy-up of protected heap. Protected allocations are now only released if it fails to reserve memory for a new allocation. Removed flushing of all protected allocations. Renamed VMEM_PROTECTED_HEAP_SIZE to VMEM_PROTECTED_HEAP_MAX_OVERHEAD. Removed recursive lock from FreeReservedMemory.
-removed recursive lock when destroying CoalesceHeap regions
-removed recursive lock from PhysicalHeap::GetSizeAligned
-removed recursive lock from VMem::CheckIntegrity
-added VMEM_CHECK_FOR_RECURSIVE_LOCKS define
-PS4 fixes/improvements


04/01/2018Version: 3.3

Summary: Support for Unreal Engine 4.18, Nintendo Switch. Improvements to PS4. Allocation tagging. Improved custom heap support

-Support for Unreal Engine 4.18
-Nintendo Switch support
-Allocation tagging. Added VMem::GetCustomAllocInfo(p). This allocs tagging of each alloction with custom data.
-Support for setting page size and commit flags on custom heaps
-removed PhysicalMemType enum for CPU/GPU and replaced with more general reserve_flags and commit_flags.
-changed VirtualMem from namespace to class and create on for each heap. Needed for the new custom heap settings.
-added VMem::Owns(p)
-renamed OVERRIDE_NEW_DELETE define to VMEM_OVERRIDE_NEW_DELETE
-support default alignment of 32 bytes
-reduce the number of critical sections the coalesce heap creates by increasing the step size and setting a max size. This was causing initialisation to fail on some platforms.
-renamed VirtualAlloc to Reservation in VirtualAlloc cache
-fixed memset type warnings
-only include sched.h or getcpu.h if recording allocs
-support for overriding malloc and new/delete for PS4
-changed VMEM_COALESCE_GUARD_SIZE to be the natural alignment
-removed SCE_KERNEL_MAP_NO_OVERWRITE flag from sceKernelReserveVirtualRange call
-improved Test_VMemAlloc test coverage


24/05/2016Version: 3.1

Summary: Optimisation for free page insertion. Optimisation and improvement of double free check.

-optimised InsertPageInFreeList. Now searches from the last inserted node instead of the beginning.
-in FSA::CheckIntegrity check that the free list is properly sorted
-FSAHeaps now flush empty pages in service thread update. This makes the heap throw away empty pages sooner
-changed hard coded value of 4 to be sizeof(void*) in trail guard double free checking
-improved doiuble free checking. Instead of checking for the free emmory marker within the allocation we check the guard bytes at the end which shouoldn't have been overwritten. We also don't need to loop through the free list to double check that it is actually free.
-changed FSA free memset to memset the entire slot size including guard bytes
-enable FSA guards in debug level 2. They are very useful and only add a small amount of memory. Also needed for tracking down double frees.
-added Test_FSAFreeStress to stress test FSA allocators
-added CorePrivatePCH.h include when compiling with UE4
-updated iOS xcode project


07/03/2016Version: 3.0

Summary: Significant optimisations: caches for releasing memory, decommitting memory, empty FSA pages and the coalesce heap. These caches delay the memory going back to the system or heap and allow for fast re-alocation. A server thread runs in the background every 30ms clearing down allocations that have been in the cache for more than a specified time.

Other optimisations come from reducing false sharing, reducing contention, more inlining, more FSAs and faster heap lookup for allocations (virtually lock free).

-re-wrote BasicFSA to be more optimal. Now uses a simple free list and never frees allocs.
-fixes for clang compiler
-removed _WIN32_WINNT define if not defined
-optional alignment arg to Alloc function (can be freed with Free)
-renamed VMem.h to VMem.h (in single file version)
-proper handling of out of memory situations. VMem will now always return NULL if no memory is available and will keep itself in an internally valid state. Also allows for failures in iniitalising the heap.
-fixed stats bug in BasicCoalesceHeap for internal allocations that are larger than 16K. Unlikely to ever happen in practice, but uncovered by test framework.
-changed VMEM_STATIC_ASSERT to use C++ static_assert
-Coalesce heap cache. Free list per size before alloc gets put back onto the heap. Reduced contention with lock per size.
-optimised GetSize. Now completely lock free in the case where the heaps have one region and reduced cache misses
-restrict keyword optimisations
-simplified code by removing single thread support and merged MT classes into main heap classes
-FSA empty page cache. Empty pages get put onto a cache before being released to avoid the page setup cost if the page is needed again.
-inlining of FSA Alloc and Free functions
-added buffers to critical code to avoid false-sharing
-FSA heaps now handle allocations of a larger size
-increased region sizes to avoid multiple regions being created
-changed some of the critical sections over to read/write locks (eliminates locks in multi-read case)
-remove all locks for finding the heap that an allocation originated from
-added PhysicalHeap for GPU allocations (not yet integrated into VMemAlloc)
-added service thread for clearing down caches
-added virtual commit and release caches. Memory is not decommitted or released immediately allowing for fast re-use
-improved allocation recording for playback profiles
-realloc will now only realloc if new size outside tolerance
-In an out of memory situation all cached are flushed immediately and the alloc retried
-Unix-based systems now use mmap/munmap to commit and decommit emmory (equivalent to virtual alloc)
-added VMEM_PLATFORM_PS4 platform define (for future suport of PS4)
-allow for 5% slack wastage of FSA sizes which allocs for many more FSAs
-changed HeapSettings to an enum to avoid unnecessary cache misses
-Simplified code by factoring out Array, List and Map classes
-vcproj now uses v140 toolset (VS2015)


07/04/2015Version: 2.4

Summary:Support for compiling with Unreal. Namespace fixes. XBoxOne support. Minor bug fix in CoalesceHeap.

-support for compiling within Unreal
-VMem is now entirely compiled out if ENABLE_VMEM is not defined
-everything is now inside of VMem namespace without using any using statements. This fixes issues with Unreal unity builds
-fixed edge case assert BasicCoalesceHeap would fail if tried to allocate allocations more than the region size.
-changed inlines to __forceinline
-fixed bug in UpdateLargestFreeNodeSize in CoalesceHeap. This would cause a slight inefficiency because the largest free block would not always be used
-added extra asserts for catching memory corruptions
-fixed compile warning in FSA.cpp related to memset
-assert to ensure that LargeHeap allocations align to the system page size
-more support for gracefully handling out of memory situations
-fixed the allocation index in the protected heap and made it start off at a random value
-replaced VMEM_UNREFERENCED_PARAM(p) in macros with ((void)0) to make sure p definitely isn't evaluated
-added support for XBoxOne platform
-removed VMEM_DELAYED_RELEASE
-changed MEMPRO_PLATFORM_XBOX360 to VMEM_PLATFORM_XBOX360
-smaller protected heap sizes for xbxoone and x86
-changed settings values to size_t to avoid a cast in VMem::Alloc
-added critical section to VMem Reserve/commit functions to keep the global stats in sync
-added unit test to check for the largest free size coalesce heap bug


15/06/2014Version: 2.3.1

Summary:Minor update. Fixed compile warnings, and fixed stats assert in debug level 4

-additional test configutations
-fixed compile warning in CoalesceHeap for x64 config
-fixed compile warnings in ProtectedHeap for x64 config
-fixed committed memory stat wen protected heap runs out of memory and has to retry (caused an assert in debug level 4)
-fixed Test_MemoryCorruptionFinderTest3 test.


20/04/2014Version: 2.3

Summary:Aligned alloc functions, CoalesceHeap optimisation, UE4 integration. Improvements to corruption finder.

-for non windows platforms changed CoalesceHeap1 size from 128K to 4MB. This was a major slowdown on non windows platforms because it caused many regions to be created.
-updated README files
-added Debug and Debug4 large page test configurations
-updated copyright notice
-removed NoReleaseBitfield for the corruption finder. Now uses a bitfield for committed pages
-optimised CoalesceHeap::GetNode for the cases where there are many regions
-changed Min and Max functions to VMem::VMin/VMem::VMax to avoid conflicts with codebases that define Min/Max globally
-added a warning if there are more than 10 coalesce heap regions
-changed the way that PageHeap corruption finder works. Now uses seperate bitfield to remember which pages are committed. Fixes the stats assert.
-fixed asserts where stats don't match up if the PageHeap runs out of memory
-re-enabled alternate pages in PageHeap when the corruption finder is enabled
-made the VirtualMem Node pool use SYS_PAGE_SIZE instead of 4K to avoid wasting memory if the system page size is larger than 4K
-changed MEMPRO_PLATFORM_GAMES_CONSOLE_1 define to MEMPRO_PLATFORM_XBOX360 and MEMPRO_PLATFORM_GAMES_CONSOLE_2 define to MEMPRO_PLATFORM_XBOXONE
-added some notes to VMemAlloc.h about general usage of VMem
-added Aligned alloc/free functions
-removed VMemCore.h include from VMemAlloc.h and replaced with VMemStats.h. This pulls in less code into the main header.
-fixed some compile settings in some of the configs
-enabled corruption finder for all windows based platforms
-Only define SYS_PAGE_SIZE if the config has not already defined it
-removed m_TableAllocSize from VMemHashMap because it wasn't being used
-changed VMemHashMap default allocation size from 4K to SYS_PAGE_SIZE
-changes warning to assert if VMemHeap::Free fails to find allocation
-fixed compile error when using protected heap
-fixed compile errors for XBOX360 platform
-added instruction for UE4 integration


20/04/20142.2 - Debug Level 4 - Page Protection
-added Debug level 4
-fixed compile error when VMEM_DELAYED_RELEASE is disabled
-typedef'd log function
-added DISABLE_BIASING define
-fixed usage_percent in stats if allocated bytes is zero (now shows 100%)
-changed VMEM_RESERVE check to VMEM_PLATFORM_WIN
-VMem_Test tests that check access violations on Debug level 4
-changed RandomGrowth in VMem_Test to have a lower phase. Exercises allocators more.
-gave VMem_Test it's own thread class to separate it from VMem
-compile fixes for Android
-
-ifdef VMEM_MEMORY_CORRUPTION_FINDER
-added NoReleaseBitfield - used in PageHeap
-disabled PageHeap alternate pages
-coalesce heap stores list of protected nodes
-disable VMEM_TRAIL_GUARDS, VMEM_DISABLE_BIASING, VMEM_DELAYED_RELEASE
-ifdef VMEM_PROTECTED_HEAP
-ProtectedHeap class
- added g_VMemSHouldProtectFn for custom choose protect function
-in VMemHeap::Alloc, try the protected heap first.
-in VMemHeap::Alloc if runs out of memory, clear some protected memory and retry


23/01/20142.1.1 - More improvements to integrity checking.
-Fixed FSA integrity checking, wasn't checking memory when page was released.

Full change log...