# PPMalloc Changes

Version 1.23.04 (unreleased)

Changes:

- Fixed a crash bug on PS4 SDK 2.000.x related to SDK changes that modified behavior of kernel virtual/physical memory allocations.

Version 1.23.03 (October, 2014)

Changes:

- Integrated Frostbite changes to PPMalloc:

- Updated EANonLocalAllocators bin selection algorithm. Reduces the number of bins to 40 and results in a more uniform distribution.
- Added InitWithoutCore function EANonLocalAllocators.

Version 1.23.02 (September, 2014)

Changes:

- Resolved warnings that occurred on iphone-arm64 configurations.

Version 1.23.01 (June, 2014)

Changes:

- Fixed a bug/limitation in the ScratchpadAllocator constructor in which you couldn't construct it with an initial count other than zero. Discovered by Coverity analysis.

Version 1.23.00 (February, 2014)

Changes:

- Added kOptionEnableMallocFailureAssert, which allows you to set a heap to assert upon Malloc failure. It is off by default in order to be compatible with the standard malloc function. This resulted in adding a new error id (kGAErrorMemoryExhaustion) and associated string.
- Fixed a couple Coverity warnings, neither of which was likely any practical consequence to users.
- Fixed a few compiler warning about registry keyword.
- Added ScratchpadAllocator, which allows you to have a per-thread "scratchpad" heap. It acts much like alloca but is more flexible, in particular because allocation size can be dynamically determined and because there are no explicit size limits. ScratchpadAllocator works by implementing a per-thread StackAllocator and wrapping its use to make user syntax simple, as shown below. ScratchpadAllocator was motivated by something similar in the Frostbite memory system. For more documentation see ScratchpadAllocator.html.

>     void DoSomething(){
>         ScratchpadAllocator scratchpad;

>         void* p1 = scratchpad.Malloc(gSize);
>         void* p2 = scratchpad.MallocAligned(10, 64);

>         scratchpad.Free(p1); // Calling Free is optional, though it allows for the
>         scratchpad.Free(p2); // potential of more efficient usage of scatch memory.
>     }

Version 1.22.00 (December, 2013)

Changes:

- Added support for PlayStation4 and Xbox One.
- Improved performance of NonLocalAllocator by adding more bins.

Version 1.21.00 (Oct 7, 2013)

Changes:

- Changed the GeneralAllocator default debug printing of file/line location (e.g. heap traces) to print the line as unsigned int instead of signed int.
- Fixed a bug in StackAllocator's constructor whereby if you specified an initial core size of ~0 then core function context wouldn't be set to the user-supplied value. Reported by Avery Lee.
- Adds a definition for the previously only declared GeneralAllocator::SetAddCoreFunction. In doing so, the CoreAddFunction typedef was given an additional parameter (coreType). This addition can't break any users because SetAddCoreFunction wasn't previously implemented.

           /// SetAddCoreFunction
           /// Specifies a callback function to be called when a GeneralAllocator instance
           /// needs to add new core memory, or when AddCore is called with a NULL pData argument.
           /// When a CoreAddFunction is specified, it completely takes over the allocation of
           /// new core, and if it returns NULL then no fallback code will execute to back it up.
           /// The CoreAddFunction returns the void* address of the core block and fills in the ppCoreFreeFunction and
           /// ppCoreExtendFunction pointers and contexts which will be later used when it's time to
           /// free or extend the core memory. *ppCoreFreeFunctionContext and *ppCoreExtendFunctionContext
           /// may be set to NULL if the CoreFreeFunction and CoreExtendFunction don't need any context
           /// information passed to them. CoreFreeFunction and CoreExtendFunction must be set or else
           /// default behavior will be used for the given platform, which may result in unexpected behavior.
           /// The CoreAddFunction must set *pReservedSize appropriately.
           /// coreType is a user-specified value that defines the type of core memory added. See enum CoreType.
           typedef void* (*CoreAddFunction)(void* userData, size_t minSize, size_t* pReservedSize,
                                            CoreFreeFunction* ppCoreFreeFunction, void** ppCoreFreeFunctionContext,
                                            CoreExtendFunction* ppCoreExtendFunction, void** ppCoreExtendFunctionContext,
                                            uint32_t& coreType);
           void SetAddCoreFunction(CoreAddFunction pCoreAddFunction, void* pCoreAddFunctionContext);

- Resolved some warnings generated under recent versions of clang for ios/osx.

Version 1.20.05 (July 11, 2013)

Changes

- Fixed the PPM_Log2(uint64_t x) function.The unfixed version had the effect on 64 bit platforms of making NonLocalAllocator choose non-optimal block sizes for Malloc requests.
- Improved NonLocalAllocator's ability to find perfectly matched blocks in terms of size/alignment. Suggested by Brian Hixon.
- Increased NonLocalAllocator's bin count from 8 to 12, in order to handle larger memory available in modern platforms. Suggested by Brian Hixon.
- Changed extras/SmallBlockAllocator's float_t usage to float, in order to be consistent with the rest of the package. In practice this will behave identically.
- Added SmallBlockAllocator::kHookTypeGrowHeapDisabled, which is set when the grow operation wants to acquire memory but allocator is not allowed to grow (allocs will overflow).
- Increased SmallBlockAllocator::Tracef's buffer size from 512 to 1024 and changed it from using vsprintf to vsnprintf.
- Made GeneralAllocator::GetUsableSize and GetBlockSize be static members instead of regular member functions. It turns out that they accessed only static data and locked a mutex which was irrelevant, as all it does is read the bytes of the input pointer.
- Added PPM_Vsnprintf to complement PPM_Snprintf.

Version 1.20.04 (April 3rd, 2013)

Changes

- Changed PPM_MIN_ALIGN to be 16 on 32 bit OSX, whereas previously it was 8. This is to match the OSX malloc and new implementations.
- Added support for unmanaged builds via EA_UNMANAGED_ALIGN. This fixes a problem that was introduced in an earlier version of PPMalloc.
- Tweaked GeneralAllocator::AddCoreInternal in such a way as to make Coverity think that pCore wasn't being leaked. The revised code is theoretically more correct anyway.

Version 1.20.03 (March 4, 2013)

Release Notes

- GeneralAllocatorDebug::Malloc, MallocAligned, and Realloc entry callback hooks now report the user-requested size as opposed to the adjusted size. The change makes the code consistent with other malloc functions in GeneralAllocatorDebug and GeneralAllocator. However, some users may be affected by this is they were somehow dependent on the previous incorrect behavior in their heap reporting. If you want the actual size of the blocks allocated with these functions, you need to pay attention to the exit callback hook instead of the entry hook. Reported by Alexandre Fortin.

Changes

- Added support for filling in HookInfo::mnSizeOutput upon calling the post-event hook for Malloc, MallocAligned, etc.
- Added GeneralAllocator::GetMaxMallocSize.
- Fixed a problem where calling Malloc with a size that's higher than supported would fail late in the function instead of right up front at the beginning of Malloc.
- Fixed GeneralAllocatorDebug::Malloc, MallocAligned, and Realloc (Calloc not affected) to specify the user-requested size in the entry hook callback, as opposed to the potentially bumped up size. This makes it consistent with Calloc and GeneralAllocator::Malloc, etc. See the release notes, as this change may affect some users.
- Exposed PPM_NLA_MIN_ALLOC_SIZE in the PPMalloc.build file so it can be tweaked in parallel with PPM_NLA_MIN_ALIGN. However, it's recommended that instead of tweaking PPM_NLA_MIN_ALIGN you instead simply use the NonLocalAllocator::MallocAligned function to request aligned memory. The end result is the same, but in a more flexible way. Suggested by Bogdan Sladaru.

Version 1.20.02 (Feburary 4th, 2013)

Changes

- Switch core entrypoint from EATest to EAMain.
- Disabled callstack functionality on Android until we have a reliable implementation for it.
- Documentation updates.

Version 1.20.01 (Janurary 7th, 2013)

Changes

- Alignment fix for the mEventId which requires 8 bytes alignment for Apple platforms, because of atomics.

Version 1.20.00 (December 10th, 2012)

Changes

- Added WiiU support.

Version 1.19.02 (November 5th, 2012)

Changes

- Added FixedAllocatorBase::GetAllocationFunctionContext accessor function. Suggested by Ryan Ingram.
- Added private copy constructor and operator= to FixedAllocatorBase in order to prevent accidental copying. Suggested by Ryan Ingram.
- Added code to GeneralAllocatorDebug::SetGuardSize to chop the max guard size if it's higher than what GeneralAllocatorDebug can support.
- Fixed an "unreachable code" warning in SmallBlockAllocator::Free. Submitted by Alban Wood, Yury Demendeev, Scott Wardle.

Version 1.19.01 (August 7, 2012)

Release notes:

- This version of PPMalloc adds a dependency on EAThread.
  Most PPMalloc users are already EAThread users, but there may be some who are not. The reason for this change is that PPMalloc has had a GetCallstack function which duplicates the one present in EAThread and has lagged on support. Similarly PPMalloc has had some mutex functionality which duplicates the functionality present in EAThread.Years ago there wasn't 100% overlap in PPMalloc and EAThread users, but now there nearly is.

Changes

- Updated callstack and mutex functionality to use EAThread. See the release notes for details.
- Added dll export declarations to some functions that didn't previously have it. This allows them to be used from PPMalloc as a DLL.
- Added improved WinRT (new Microsoft mobile OS variation of Windows) support.
- Worked around some iPhone clang compiler pedantic warnings.
- Fixed missing Apple (iOS, OS X) callstack support. It was supposed to be migrated from the EACallstack package but got missed.

Version 1.19.00 (July 3rd, 2012)

Release notes:

- This version changes the default behavior under 64 bit platforms such that the minimum allocation, alignment, and alignment offset is 16 instead of 8. There may be some code that's dependent on it being 8. For example, the EAIO package EAIOZoneObject class allocates memory with an alignment offset of 8 and fails under this new version. The EAIO package has been updated to handle this.
- This version changes the default behavior for the case where you construct with a specified amount of core memory. It is no longer rounded up to mnNewCoreSize but rather the value you specified is used as-is. This prevents surprises, such as if the user constructs with a core memory size of 64K but 16MB is allocated instead.

Changes

- Added full 64 bit support to GeneralAllocator and NonLocalAllocator. For 64 bit platforms the following is now default:
  - Core memory can be > 4GB per core block.
  - Individual allocations can be > 4 GB.
  - Minimum alignment is 16 bytes.
- Added the ability for the user to extend core memory via a callback CoreExtendFunction. Along with this is a new AddCoreEx public function.
- The allocating and freeing of core memory has been cleaned up and made more robust by way of defining a CoreType enum which describes core memory and allows for reliably knowing how to free it and extend it. Previously there was little flexibility in this regard and the requirements were hard understand.
- Added kHookTypeCoreExtended, which allows you to hook the extension of core memory, whether done internally or via a callback to the new CoreExtend function.
- Unix and Apple platforms now support kOptionExecutableCore. When this flag is enabled, automatically allocated core memory is executable.The option is ignored on platforms that don't support allocating executable memory. If this flag is enabled and executable memory is supported but fails, the core allocation fails and the user core allocation fallback is called.
- Expanded support under Microsoft platforms to use VirtualAlloc on OSs other than Windows and XBox 360 when available.
- Made it so that when you construct or Init GeneralAllocator with a specific requested core memory size, it is not rounded up to mnNewCoreSize (typically 16 MB), but rather is rounded up only to the minimum necessary (typically page size of 4096 bytes).

Version 1.18.01 (May 7, 2012)

Additions

- Added assertions to GeneralAllocator to verify that the max core size is not being exceeded.
- Added an option to GeneralAllocator to specify the size_type used. Previously it was hard-coded to uint32_t.

Changes

- Reduced NonLocalAllocator's min alloc and alignment sizes down to 1. There was no specific reason it needed to be 16 as before. Added the PPM_NLA_MIN_ALLOC_SIZE config define which lets you set the min size to a custom value. PPM_NLA_MIN_ALIGN already existed.
- Reduced NonLocalAllocator's max alloc size to (size_type max / 2), which means 2GB per allocation with a 32 bit size_type and UINT64_MAX with a 64 GB size_type. Previously it was double that. This came about to the change that reduced the min size to 1.
- Improved the assertions for NonLocalAllocator in the case that the user attempts to alloc >= max alloc size.
- PPM_CT_ASSERT now uses C++ static_assert when available, though EABase.
- Updated documentation for realloc to fix a misstatement.
- Updated code to resolve some defects reported by Coverity. In no case were these reports indicative of an actual runtime bug, but the changes done are useful anyway.

Bug Fixes

- Fixed a possible assertion failure for the case PPM_MALLOC_AS_MMAPALLOC == 1 and doing a memory-mapped alloc request over.
- Fixed a bug introduced in v1.17.01 which prevented building on EA_PLATFORM_PS3_SPU. Submitted by Andreas Andersson.

Version 1.18.00 (March 6, 2012)

Additions

- Added PSVita platform support (EA_PLATFORM_PSP2).
- Added Airplay/Marmalade and CTR platform debug output support.

Bug Fixes

- Fixed XBox 360 warning related to InitializeCriticalSectionAndSpinCount returning void instead of a count like Windows does.
- Fixed bug in TrimCore whereby FreeCore returning false would result in the core not being returned to the heap correctly. Tentatively verified by Tim Smith.
- Removed support for sbrk on Unix when allocating additional core memory blocks. mmap is now used exclusively. Made sure that FreeCore frees memory blocks that were allocated using mmap. Previously there was a problem where if sbrk failed then a backup call to mmap succeeded, on shutdown the free didn't realize it should be freeing with munmap. There is still a to-do for this to formalize the naming and execution of alternative core allocation mechanisms.

Changes

- EASmallBlockAllocator - Added assert to tell the user when they try to use a min alignment/pool increment size < sizeof(ptr) as this is an error condition. This is useful for 64 bit platforms.

- Did some unit test changes for iOS to allow easier automated unit testing.
- Implemented explicit support for the rename of the Airplay platform to Marmalade. This is a mobile middleware platform which used to be called Airplay but that name conflicted with some Apple technology, so they changed the name to something equally senseless.
- Added code to EAGeneralAllocatorDebugWin32.cpp to prevent users from accidentally compiling it into a Win64 build and wondering why it doesn't work. You need to use EAGeneralAllocatorDebugWin64.cpp for Win64.
- Moved the variable declaration for GeneralAllocator AtomicUint mEventId to be naturally 64 bit aligned. This may help with handling of the clang compiler on iOS, which fails to align 64 bit values on 64 bit boundaries.

Version 1.17.04 (January 11, 2012)

Changes

- This version explicitly supports the Freebox platform.
- Removed unnecessary mutex lock in GeneralAllocator::GetBlockSize. Submitted by Avery Lee.
- Fixed a couple GCC warnings related to "variable 'pPrevChunk' set but not used [-Werror=unused-but-set-variable]" that you might see if using some recent versions of GCC.
- Added playbook-x86 build target support.
- Added GeneralAllocator option kOptionExecutableCore. When enabled this attempts to allocate new core memory that has executable permissions. For the most robust handling of this it's best if the user takes over core memory management instead of using kOptionExecutable core to get the default mechanism to do it.
- Worked around some warnings that the VC++ /analyze option generates.
- Changed filename case of some Windows headers to match the case of the files in the Windows SDK. This doesn't fix any bugs but does allow our case sensitivity checking tools to generate clean output.
- Fixed a unit test warning related to unmatched warning pop pragma on XBox 360.

Version 1.17.03 (November 21, 2011)

Additions

- Added GeneralAllocator::kOptionLockDuringHookCalls, which causes the GeneralAllocator mutex lock to stay locked during calls to user hooks. If you can guarantee that your code won't cause deadlocks then this will allow GeneralAllocator to run a little faster and causes hook calls to never appear out of order to the user. Along with this is a eventId which is incremented for every Malloc, Free, Calloc, Realloc, etc. call and passed to the user in the hook call. This provides another means for the user to deal with potentially re-ordered hook calls for the case that the GeneralAllocator mutex isn't locked during hook calls.
- Added SmallBlockAllocator diagnostics functionality. Submitted by the Tiburon studio.

Bug Fixes

- Fixed a memory leak in StackAllocator. Submitted by Paul Terry.

Changes

- Updated AllocationRecorder to allow the user to supply an alternative to fopen/flclose etc file system functions. Fixed a bug while at it where the previous code was potentially calling fclose twice.
- Removed an assertion in SmallBlockAllocator::Pool::AllocateCoreBlock for the case of the return value being NULL.

Version 1.17.02 (August 18, 2011)

Additions

- Added FreeUnusedCore to FixedAllocator. Implemented by Brian Hixon.
- Added CTR support.

Bug Fixes

- Fixed non-bulk build compile failure on iOS (e.g. iPhone). Reported by James Brookes.
- Fixed a rare bug where on some platforms (usually Unix) there could mistakenly be a chunk that's flagged as memory mapped which isn't.
- Fixed a bug which could cause a crash in rare cases where a memory request just about bumped up against the core block size.
- Fixed a potential bogus assertion failure in CheckRemallocedChunk. Reported by Bob Flanagan.

Changes

- Implemented a fix for a scalability problem for the case that huge numbers of free memory chunks collected in the same free list ("large bin"). This change was non-trivial and won't be considered stable until it gets more testing beyond the unit tests. Also it necessarily adds 1K of memory usage to the size of a GeneralAllocator instance. However, this feature comes at the cost of 1K of additional memory usage by a GeneralAllocator instance and a small performance drop due to the maintenance of additional data structures. The PPM_FREE_LIST_SCALABILITY_ENABLED config option can be used to disable this functionality.
- Made it so that GeneralAllocator::AddCore lets users add core of a size smaller than the page size. Previously its rounding down of core sizes to nearest page size caused it to round small sizes down to zero. Requested by Alexandru Ene.
- VirtualAlloc calls under Microsoft platforms now try to allocate executable memory in addition to being read/write.

Version 1.17.01 (May 4, 2011)

Additions

- Added Playbook support
- Added codestripper support

Bug Fixes

- Fixed a bug where pushing a bookmark twice and then popping the bookmark in the stack allocator could cause the next bookmark's memory to be freed.
- Fixed a multithreading problem that could occur in MallocInternal, related to calling CallMallocFailureFunction. Reported by Ryan Butterfoss.

Changes

- Updated unit tests to use __android_log_write on the Android platform. Android doesn't support C printf as a debug output destination.

Version 1.17.00 (December 14, 2010)

Additions

- Added an IsConstructed function to tell if an instance has constructed. This function works only in the case that the GeneralAllocator memory is known to be zeroed before construction, as with a global variable.
- Added StackAllocator::ValidateAddress and ValidateHeap functions.
- Added the PPM_FASTBINS_ENABLED option to config.h.

Bug Fixes

- Fixed a bug with the 'GetCallStack' method on Xenon, where it could read past the end of the input buffer.
- Fixed bug in GeneralAllocator::GetLargestFreeBlock where it could report the wrong answer. Reported by Aleksander Trajkov.
- Fixed assertion in NonLocalAllocator::AddNodeToFreeList where an assertion could mistakenly trigger if you have PPM_NLA_DEBUG_DATA_SUPPORTED defined to 0. Reported by Andy Younger.
- Fixed a couple related bugs in AddCoreInternal and ExtendCoreInternal which would result in heap corruption. Thanks to Henrik Karlsson from DICE for solving this while I was away on loan to another project.
- Fixed a bug in StackAllocator where in rare cases PopBookmark could result in a corrupted bookmark stack.
- Fixed a bug in StackAllocator where compilation would fail if PPM_INCREMENTAL_OBJECTS_ENABLED was 0. However, it defaults to 1 and nobody has set it to 0. Probably the option should be removed altogether and the code made cleaner due to removal of #ifdefs related to it.
- Fixed a multithreading bug in the usage of GeneralAllocatorDebug where an assert could be triggered and invalid debug information applied to blocks.

Changes

- Added a print EXIT(n) at the end of the unit tests on wii to support EARunner_Wii; it will indicate to the runner that the test is completed.
- Reduced the memory size for some of the tests on wii because they were exhausting the malloc heap.
- TraceFunctionDefault now supports Android's __android_log_print, as Android doesn't support debug printing with printf.

Version 1.16.01 (June 01, 2010)

Release notes

- This version provides updates for mobile platforms and for the CodeWarrior (1.3) and PS3 SN (330) compilers.

Version 1.16.00 (May 27, 2010)

Release notes

- Added mobile phone support: Palm Pre, Samsung bada, and Google Android. More mobile platforms to eventually follow.
- Moved the following to the extras directory: EAGeneralAllocatorSTL.h, EASystemAllocator.h. These are old files which aren't used any more by any identified users. EAHandleAllocator.h/cpp will got there soon too, once some depending code goes away.
- Removed some GCC 4.4 Linux warnings related to strict aliasing.
- Fixed mutex buffer size for iPhone and related platforms.
- Fixed a bug (introduced in 1.15.01) in the build file config option system. Reported by Sean Halliday.
- Removed some of the platform-specific PPMalloc/source directories and made them use the generic PPMalloc/source/glibc directory.

Version 1.15.05 (January 14, 2010)

- Removed EANewDelete.cpp.
- Moved all configuration parameters to a single header: PPMalloc/internal/config.h. These parameters are all user-overridable via a header file or via nant build properties.
- Added a PPMALLOC_USER_CONFIG_HEADER option to PPMalloc/internal/config.h so the user can #define a header file for PPMalloc to always compile before anything else. Suggested by Bob Summerwill.

Version 1.15.04 (December 10, 2009)

- Updated EAGeneralAllocatorDebugWin64.cpp to deal with new Windows SDK versions which now define stack functionality themselves.
- Fixed an iPhone compiler warning regarding a printf %x format specifier. Reported by Cliff Hammerschmidt.
- Implemented workaround for a bug in the ARM compiler which caused it to crash while compiling a macro.
- Updated nant .build file to allow overriding of most config parameters. Previously only the main ones were available for overriding.

Version 1.15.03 (November 18, 2009)

Additions

- <none>

Bug Fixes

- Added compile fix for an unusual build configuration. Reported by Darryl Gates.
- Removed a couple compiler warnings that result from using --diag_error=68 (a non-default warning option) with SNC. Reported by Jeff Skelton.

Changes

- Adjusted the code to avoid some 'remark' output from SNC when compiling with SNC's -Xdiag=2 option.
- The package now builds under SNC for PS3 with the -Xfastmath=1 options. In practice these probably won't make much difference for this package.

Version 1.15.02 (October 5, 2009)

Additions

- Added full support for Linux/Linux64 callstack reading in EAGeneralAllocatorDebugLinuxX86.cpp.

Bug Fixes

- Fixed some Linux64 / GCC 4.3 compiler warnings.
- Fixed a new PS3 SNC 300 compiler warning.

Changes

- Added Lock usage to ReportHeap and ReportBegin/ReportEnd so they no longer require the user to manually implement thread safety. Suggested by Brandon Cauthers.
- Modified EA_XBDM_ENABLED slightly. Now it keys off of being equal to 0 or 1 instead of being undefined or defined. A result of this is that you may need to globally define EA_XBDM_ENABLED to 1 in a release build if you want it to work there. For Framework2/Nant users, the PPMalloc.build file supports using EA_XBDM_ENABLED=[0|1] in the masterconfig.xml file. Suggested by Kevin Perry.
- Modified PPMalloc.build to disable warnings as errors for end users. This is to allow builds to be less broken by compiler warning changes such as that addressed above in the SNC 300 bug fix.

Version 1.15.01 (August 11, 2009)

Additions

- Added examples/MinimalAlignmentAllocator.h/cpp. Provided by David Cope. Removed two other files from the examples directory, as they are no longer relevant.
- PPMalloc: Added GeneralAllocator kOptionCoreTopDown option.

Bug Fixes

- Fixed compiler warning in SmallObjectAllocator::GrowPool for the case of PPM_DEBUG >= 2.
- Fixed memory overwrite bug in Win64 GetCallstack under VS2005. This occurred due to incorrect Microsoft documentation regarding the RtlVirtualUnwind function. Found by Tom Van Dijck and Albert Ho.
- Fixed bug whereby GeneralAllocator::mbUnsortedBinEnabled was not initialized in the constructor. This could result in the allocator having slightly different performance characteristics and different block placement, though it wouldn't result in crashes or other fatal behavior. Reported by Ralf Kornmann.
- Fixed potential bogus assertion in GeneralAllocatorDebug::SetDebugInfoForAllocation.
- Fixed Win64 bug in SmallBlockAllocator which could cause a crash in Free, and a nearly identical bug in SmallObjectAllocator which could cause a crash in GetAllocationInfo. These crashes could occur if the alllocators are using core memory which is at addresses beyond 2^32, as the bug was due to casting an address to uint32_t, which isn't 64 bit safe.

Changes

- Revised the .build file to expose all significant config defines as user-controllable global properties.

Version 1.15.00 (April 6, 2009)

Additions

- Added SmallObjectAllocator::kOptionAlwaysFreeCoreBlocks, which more aggressively frees unused pool memory. It is disabled by default for backward compatible heap behavior.

Bug Fixes

- Fixed bug in ReportHeap whereby only the first core block would be reported if you have multiple core blocks and your block type flags included only kBlockTypeCore.
- Fixed bug in SmallObjectAllocator.h whereby it was missing header include guards. Reported by Dominic Mathieu.
- Fixed bug in SmallObjectAllocator.cpp whereby it would give a compile error if PPM_NULL_POINTER_FREE_ENABLED was disabled. Reported by Dominic Mathieu.
- Fixed bug in Win64 callstack functionality that could have caused a crash. This bug is noted in the release notes for PPMalloc 1.14.04. Found by Tom Van Dijck.
- Fixed some compiler warnings related to strict aliasing with GCC/PS3.

Changes

- Revised the default debug fill values for 360 and PS3 to be improved. The new values are more likely to trigger an exception (as opposed to silent bad behavior) if used as a pointer than the previous values. See PPMalloc/include/internal/shared.h for the definitions.
- Made the GetUsableSize function (present in many of the heap classes) have consistent documented behaviour regarding a NULL input pointer. It now always returns -1 for all PPMalloc heap classes.
- Disabled assertion in EASmallObjectAllocator::MallocAligned. It seemed to be triggering, though it's normally not supposed to.
- Disabled assertion in GeneralAllocatorDebug::SetDebugInfoForAllocation regarding (nDifference < 32768).
- SmallBlockAllocator::Pool::ReportEnd and SmallObjectAllocator::ReportEnd now always clear the ReportContext, even in non-debug.

Version 1.14.04 (December 9, 2008)

Release Notes

- One user has reported that the Win64 callstack functionality crashes in a debug-release build, but not others, and has done so since it was first introduced. This crash hasn't yet been identified or fixed, but it doesn't seem to occur for most users. (Update: Fixed in 1.14.05)

Additions

- Added kOptionMMapPageSize, which allows you to tell 360 and PS3 builds to use large virtual page sizes. You can use a size of 65536 or greater on 360 or a size of 1048576 on PS3 to trigger usage or larger page sizes (64 KiB and 1 MiB respectively).

Bug Fixes

- Fixed bug in GeneralAllocator::ValidateAddress for mapped memory (Windows/Unix) whereby it would not validate the list chunks (pMMapChunk) that it intends. Reported by Hitesh Shah.
- Fixed bogus assert in SmallBlockAllocator::Init. Reported by Daniel Craig.
- Fixed Win32/Win64 bug in GeneralAllocator::ExtendCoreInternal where the extension size was not a multiple of 65536. Reported by Andrew Farrier.
- Fixed missing call to mHashTable.Clear() in NonLocalAllocator::Shutdown(). The result was that reusing a NonLocalAllocator would result in redundant hash table entries (the hash table is a list of valid allocator pointers in debug builds). Reported by Brandon Ehle.

Changes

- <none>

Version 1.14.03 (September 1, 2008)

Additions

- Added VS2008 support. This affected only the Win64 build; the Win32 build required no modifications.

Bug Fixes

- Fixed pc64 code callstack code generation problem in optimized builds by disabling compiler optimization around a problem function.
- Fixed bogus assertions in SmallObjectAllocator::Malloc, Free, ValidateHeap, and GrowPool. Reported by Michael Schwartz.
- Fixed PPM_DEBUG = 3 compile failure in SmallObjectAllocator. Reported by Luc Isaak.
- Fixed crash bug in GeneralAllocator::MallocInternal when memory is exhausted with thread safety disabled. Reported by Eric Tolman.
- Fixed Unix bug in GeneralAllocator::AddCoreInternal which was introduced in PPMalloc 1.01.00 (a.k.a. 1.1.0). Reported by Christopher White.

Changes

- Updated PS3 version of GetCallStack (copied from the EACallstack package) to support more than just one callstack entry and to support SPU.
- Updated Win32 version of GetCallStack to use DuplicateHandle. Apparently sometimes the Microsoft DbgHelp library doesn't like the GetCurrentProcess pseudo-handle.

Version 1.14.02 (June 10, 2008)

Additions

- <none>

Bug Fixes

- Fixed crash bug in GeneralAllocator::MallocAligned when kAllocationFlagBestFit, kAllocationFlagEndFit, and kAllocationFlagAlwaysAlign were used together. These are new flags which aren't likely yet being used by many. Found by by Michael Schwartz.
- Fixed assertion failure in SmallObjectAllocator. This isn't likely to have been resulting in any ill behavior.
- Fixed pc64 (Win64) callstack function return value whereby it could return a value greater than intended. This could have crashed if you gave it a small stack space to work with.
- Fixed pc64 (Win64) SmallBlockAllocator core block alignment bug. This isn't likely to have been resulting in any ill behavior.
- Fixed pc64 (Win64) potential SmallBlockAllocator MallocAligned failure when it could have found an aligned block.

Changes

- Disabled pc64 (Win64) compiler optimization for the GeneralAllocatorDebug::GetDebugInfoForAllocation function, due to code misgeneration under some configs.

Version 1.14.01 (May 19, 2008)

Release Notes

- SmallObjectAllocator now enforces the setting of the core memory allocator before calling Init, whereas previously it required this but didn't enforce it. This change may break code, though it break will always be immediately detected and is trivial to fix: simply put the SetCoreAllocationFunction call before the Init call.

Additions

- <none>

Bug Fixes

- Fixed NonLocalAllocator free core callback misreported size. Reported by Henrik Karlsson.
- Changed PS3 minimum core size from 65536 back down down 4096. It was changed to 65536 in v1.14.00 but didn't need to be so.

Changes

- SmallObjectAllocator now allows for a user-determined max pool size instead of a hard-coded predefined version. Implemented by Philip Kavan.
- As noted in the releast notes above, SmallObjectAllocator now enforces the setting of the core memory allocator before calling Init, whereas previously it required this but didn't enforce it. This change may break code, though it break will always be immediately detected and is trivial to fix: simply put the SetCoreAllocationFunction call before the Init call.
- Added FAQ entry related to XBox 360 crash dumps omitting physical memory. Prompted by Chris Jacobson.
- Improved the GeneralAllocator::ValidateHeap function to catch a small block overrun which it didn't catch previously. Prompted by an observation by Michael Schwartz.

Version 1.14.00 (April 11, 2008)

Additions

- Added GeneralAllocator::kOptionEnableUnsortedBin. Prompted by observations by Ralf Kornmann.
- Added StackAllocator::GetTopBookmark.
- Added NonLocalAllocator::TrimCore, which frees up unused core memory. It is similar to GeneralAllocator::TrimCore.
- Added PS3 mapped memory option to GeneralAllocator to match Windows and XBox 360. As with other platforms, you can explicitly request mapped memory via kAllocationFlagMMap and you can get mapped memory via Malloc if your request is greater than kOptionMMapThreshold and no other free memory is available. You can disable mapped memory on startup by setting kOptionMMapMaxAllowed to zero. Suggested by Henrik Karlsson.

Bug Fixes

- Fixed bookmark memory leak in StackAllocator. Reported by Chris Corliss.
- Removed usage of __out and __in for Win32 build for better portability across Windows versions. Reported by Andrew Willmott.
- Fixed bogus validation failure in GeneralAllocatorDebug introduced in v1.12.00. Some additional debug validation was added in 1.12.00 but it mistakenly indicated that a certain kind of internal block was bad when it was fine.
- Fixed bug in NonLocalAllocator::MallocAligned whereby an allocation request of a size that exactly matches the entire heap size would fail unless the user specified kAllocationFlagBestFit. Reported by Brandon Ehle.
- Fixed memory leak in NonLocalAllocator whereby a single 32 byte node per core block might be leaked. There is usually only one core block, though there can be a few if the user chooses to setup NonLocalAllocator to do so.
- Fixed potential false positive return value of GeneralAllocatorDebug::ValidateAddress for the case whereby the queried memory was actually in a delayed free list. This has been on the to-do list for a number of months, though the bug is unlikely to have affected anybody.

Changes

- StackAllocator::PushBookmark now returns bool instead of void.
- NonLocalAllocator debug memory usage improved for the case whereby there isn't debug info. Suggested by Simon Everett.
- NonLocalAllocator now frees any memory leaks for the user on Shutdown.

Version 1.13.02 (February 16, 2008)

Additions

- Added built-in callstack support to pc64 configuration.

Bug Fixes

- Fixed some PS2 compilation errors that were introduced with v1.13.00. Thanks to Philip Dunstan and James Fairweather for the reporting and fixing.
- PS2 callstack functionality has been restored. It was unintentionally disabled starting with v1.11.00.
- Fixed bug in Examples/EAStompAllocator.cpp/MallocAlignedDebug() whereby it would miscalculate aligned_size. Submitted by Michael Schwartz.

Changes

- Changed GeneralAllocator::AddCore error return string from 'invalid core' to 'exhausted memory'. Suggested by Avery Lee.
- Added printf("\32") to end of unit test under PS3 and PS2. This indicates to the SN tools that the app is done.
- Bogus unit test failure report on PS3, Wii fixed.
- Win32 and Win64 unit tests now support DLL mode.
- Revised the unit tests to take less time to run.

Version 1.13.01 (December 21, 2007)

Additions

- Added support for the SN PS3 compiler.

Bug Fixes

- Fixed compiler warning generated by GCC 4.1.x and PS3 SDK 210+.

Changes

- SmallBlockAllocator documentation updated. Submitted by Henry Allen.
- SmallBlockAllocator natively supported by the build file and associated initialize.xml file. Submitted by Henry Allen.

Version 1.13.00 (November 8, 2007)

Release Notes

- An alternative SmallBlockAllocator written by Henry Allen of Tiburon has been added to the extras directory. This allocator is called SmallBlockAllocator as opposed to the SmallObjectAllocator present in the PPMalloc source directories and can be used in parallel with SmallObjectAllocator for comparison purposes. This is a candidate replacement or permanent alternative to the existing SmallObjectAllocator. See the SmallBlockAllocator.html documentation for a description of it. Any comments on this are welcome and can be posted to the UTF Users mailing list or possibly directly to the maintainers of PPMalloc.

Additions

- Added Python script to examples directory which converts Juice recordings to PPMalloc EAAllocationRecorder recordings.
- Implemented support for aligned memory with (kAllocationFlagPerm | kAllocationFlagBestFit). This was prompted by the Medal of Honor Airborne for PS3 project, but is useful in general.
- Added FAQ entry on how to replace malloc/free (as opposed to new/delete) on PS3/GCC.
- Added kOptionFailureValue to NonLocalAllocator. It lets you specify the malloc failure return value, which defaults to being NULL.
- Added GeneralAllocatorEphemeral.cpp to the extras directory. This is shows how to implement a trick called "ephemeral allocation."
- Added SmallBlockAllocator to the extras directory as potential new module for users to try out.

Bug Fixes

- Fixed bogus assert in GeneralAllocator::CheckChunk for case when user defines PPM_DEBUG_PRESERVE_PRIOR to zero. Submitted by Phillip Kavan.
- Fixed bogus assert in SmallObjectAllocator::GrowPool. Submitted by Phillip Kavan.
- Fixed bogus validation failure in GeneralAllocator::ValidateAddress for memory mapped allocations (on platforms/configurations that support such allocations, as with Windows). Submitted by Hitesh Shah.
- Fixed compile failure in NonLocalAllocator and SmallObjectAllocator for PPM_DEBUG >= 2.
- Fixed 64 bit platform bug in SmallObjectAllocator whereby it was expecting an offset to be 64 bit aligned but it was only 32 bit aligned, resulting in an assertion failure. It is not immediately clear if this would result in incorrect runtime behavior. Discovered by the unit tests.
- Fixed compile failure in EAAllocationRecorder for the case of multithreading being disabled. Reported by Simon Golding.
- Fixed declaration of InitializeCriticalSectionAndSpinCount for the case of building with VC7 or earlier and not using Framework2/eaconfig. InitializeCriticalSectionAndSpinCount is only enabled by <windows.h> if _WIN32_WINNT >= 0x0403, yet it is present in all significant versions of the Windows kernel. Reported by Jeff Dixon.

Changes

- The unit tests have been augmented to catch more compile problems due to unusual build/option configurations. Nearly all the bugs that are fixed in this release and the previous (1.12.01) release were due to the package being built in some way or with some configuration that isn't default. So additional unit tests which exercise configuration options have been created to help identify this in the future. The PPMalloc package has a number of configuration #defines (e.g. PPM_MIN_ALIGN) which tweak the way it works, but these create testing and maintentance problems.
- EAAllocationRecorder has been augmented. The Playback function now lets you play a single line specified by char*, the unit tests have been mildly augmented, the documentation has been improved. This change modifies the interface of EAAllocationRecorder, though it could affect only tools and testing applications and not runtime usage.
- Deprecated kOptionEnableHighAllocation; it is now considered always enabled. This is a step in the effort to simplify GeneralAllocator. Similarly, PPM_HIGH_SUPPORTED is also no longer recognized.

Version 1.12.01 (September 6, 2007)

Additions

- Added unit test called TestDisableSystemAlloc.

Bug Fixes

- Fixed linker error introduced recently in v1.11.03 regarding PPMMutexLock/PPMMutexUnlock. Found by Phillip Kavan and Brian Hixon.
- Fixed compile error in EAAlloctorInterface.cpp regarding kDefaultFillValueFree that was created in the a recent version (1.11.03). Found by Martin Griffiths.
- Fixed usage of © to (c) in the version.h file so that the code can be compiled under any locale.
- Fixed bug in GeneralAllocator::CheckState whereby it could mistakenly return that the check failed when in fact it was OK. Submitted by Phillip Kavan.
- Fixed bogus assertion failure in EAStackAllocator.cpp

Changes

- Removed support for misspelled SetHookFuncton (the correct spelling is of course SetHookFunction).
- AddCore(0, someSize) now unilaterally commits all of someSize on platforms that support the concept of reserved vs. committed memory (e.g. Win32). Previously this could result in unused reserved address space, a situation which the user probably doesn't want.

Version 1.12.00 (July 23, 2007)

Release Notes

- ReportHeap now supports kBlockTypeCore as described below. This may affect user code that was using ReportHeap but was ignoring the block type flag.

Additions

- ReportHeap (and friends) now supports kBlockTypeCore. Arguably, the addition of this functionality constitutes a bug fix, as the ReportHeap API has always implied that kBlockTypeCore would be supported.
- Added GeneralAllocator::ValidateChunk() which allows per-Chunk debug validation.

Bug Fixes

- Fixed bug on Windows whereby core memory is not freed during shutdown when freed by the internal VirtualFree. Bug found by Alexis Kwong.
- NonLocalAllocator fix for metrics gathering, submitted by Johan Andersson.
- Fixed InitializeCriticalSectionAndSpinCount usage on XBox (original XBox, not XBox 360).
- Fixed bug in Win32 version of DescribeCallStack whereby very long symbol names could cause a buffer overrun. Bug found by Ralf Kornmann.

Changes

- Changed the guard fill failure reporting to give the user more information. Suggested provided by Avery Lee.
- Updated the page protected allocator to be a formally implemented .h/cpp file pair and a class called StompAlocator. This version merges in the latest stompallocator supplied by Kevin Perry.
- Win32 and Win64 builds use the MEM_WRITE_WATCH flag in VirtualAlloc in debug builds. This will allow for much faster heap validation. The PPMalloc unit test now has an initial test function for doing such a fast heap validation, and this will likely find its way into GeneralAllocator::ValidateHeap soon. This was based on a suggestion by Ralf Kornmann.

Version 1.11.03 (May 30, 2007)

Release Notes

- This release introduces the first public beta versions of NonLocalAllocator and SmallObjectAllocator. These classes are fully functional, mostly optimized, and fairly well tested. However, there may exist bugs, limitations, or design flaws. Feel free to comment on these or try them out.
  Thanks for the suggestions provided by Aaron Rehaag, Andrew Brownsword, Brian Hixon, Alex Fry, Brent Thale, Chris Cummings, Daniel Craig, David Galeano, Frank Barchard, Icer Addis, James Fairweather, Mike Rayner, Nicholas Hendricks, Rob Povey, Scott Randolph, Stefan Boberg, and Stu McKenna.

Additions

- <none>

Bug Fixes

- <none>

Changes

- NonLocalAllocator and SmallObjectAllocator are now considered to be of beta testing status.

Version 1.11.02 (May 16, 2007)

Additions

- <none>

Bug Fixes

- Fixed compile warnings in dll configurations related to NonLocalAllocator::HashTable.
- Fixed compile error that could occur when building a .sln file that was generated by nanttovstools. This was due to a typographical error in PPMalloc.build.
- Fixed unit tests to support compiling under VC++ when the -GX compiler option is enabled. Previously eaconfig cross builds of the unit tests would fail due to this.

Changes

- Changed the PS3 mutex code to use sys_lwmutex instead of sys_mutex. The former is significantly faster in the case of non-waiting locks.
- Revised the file organization to accomodate the addition of NonLocalAllocator. This entailed moving functionality that is shared between GeneralAllocator and NonLocalAllocator to shared source files such as shared.h/cpp and mutex.h/cpp/inl.
- Revised .build file to enable -Wp64 under VC++/Win32.

Version 1.11.01 (May 4, 2007)

Additions

- Added initial header and source files for EANonLocalAllocator and EASmallObjectAllocator. These are not yet usable.

Bug Fixes

- Fixed mutex compiler error for non-Linux based Unix variants such as BSD and Cygwin.

Changes

- Removed version #defines from individual allocator headers. They were tedious to maintain and didn't turn out to be necessary.
- Overhauled the unit test system to make it easier to maintain and extend.
- Coalesced the build files into a single ppmalloc.build file.
- Removed version defines from header files. These weren't being used and increased maintenance work.

Version 1.11.00 (April 11, 2007)

Release Notes

- This release does not include the two major features currently on deck: NonLocalAllocator and SmallObjectAllocator. These features will hopefully be in beta form in the next major package release after this one.

Additions

- Added Cygwin compatibility for both the runtime and the unit tests.
- Added a FAQ entry regarding ptmalloc.
- Added missing sndbs and IncrediBuild entries in masterconfig.xml so that distributed builds work. Had to add an extra warning suppression (probably VS2003 vs VS2005) and a dependency from the tests onto the runtime so the SLN workflow works. Bob Summerwill implemented this.
- Added a new unit test: TestDebugDataLocationSeparate.

Bug Fixes

- Fixed bug in StackAllocator (in the FreeObjectsEx function) whereby a bookmark placed at the top of the stack but which refers to a previous core block could become stale and later cause a crash because the memory for the bookmark itself would be gone.
- Fix for a couple compiler warnings under Linux/GCC3.4.
- Fixed CodeWarrior/Wii compiler warnings and bulk-build incompatibility.

Changes

- Revised the assertion failure mechanism to give the user significantly more information about the failure.
- InitializeCriticalSection usage changed to InitializeCriticalSectionAndSpinCount. Multiprocessing is becoming prevalent and users the introduction of a spin count has improved performance for EA games that have tried it in PPMalloc. So we make this available in the default distribution.
- Removed a couple assertions from StackAllocator; they didn't truly indicate usage violations.
- Implemented debug build memory filling optimization in ClearFastBins that results in more efficient debug memory filling. If you are seeing slow performance of ClearFastBins in debug builds then this should fix your problem.
- Switching PS3 asm "trap" usage to asm "tw 31,1,1". That makes friendlier to debugging.

Version 1.10.00 (Feb 8, 2007)

Additions

- Added DynamicSOA (Dynamic Small Object Allocator) to the examples directory. If such a thing becomes recognized as universally useful, it can perhaps be promoted to the main supported source modules. DynamicSOA was contributed by Kosta Arvanitis.

Bug Fixes

- Fixed some Metrowerks compiler warnings under Nintendo DS.
- Robusitified the ValidateHeap function to better deal with corrupted heaps. If the heap is corrupted, it will much more likely assert and/or return false than it would crash.
- Fixed potential NULL-pointer reference exceptions in calls to PPM_ASSERT(this, PPMMutexGetLockCount(mpMutex) > 0);
- Fixed bug in Malloc whereby if the user requested a block from high memory, but a block from low memory was in the fastbin cache, it would return the fastbin cache block.
- Fixed FixedAllocatorBase::Shutdown to set mpHeadChunk to NULL. Without this you can't safely re-use a FixedAllocatorBase that has been Shutdown.

Changes

- StackAllocator no longer assumes that Malloc will always succeed. It now returns NULL if there is no core memory nor can any new core memory be allocated.
- Added a slight optimization to StackAllocator to use EA_UNLIKELY for some of the if statements. EA_UNLIKELY is defined in EABase.
- On XBox 360 XPhysicalAlloc with fast 16MB pages is now used instead of malloc to do a default core alloc. This was contributed by Simon Golding, Nicholas Hendricks, and Barry Feather.

Version 1.09.02 (November 14, 2006)
Release Notes

- This version makes instances of gpEAGeneralAllocator and gpEAGeneralAllocatorDebug whereas previous versions required the user to do so. As a result, any existing user code that declares these variables will result in a duplicated symbol linker error. This can be resolved by removing the user version of the variable or by defining PPM_ENABLED = 0 in the PPMalloc build. See PPMalloc/source/setallocator.cpp for where this occurs.

Additions

- This version adds a new configuration define called PPM_MIN_ALIGN. This sets the minimum alignment for allocated memory to be a value greater than the usual value of 8. This option is not yet fully tested and isn't yet supported. It is planned to be so in a future release.

Bug Fixes

- <none>

Changes

- Added support for VS2005 (VC8).
- Changed the default EABase in masterconfig.xml to be EABase 2.0.12 instead of the previous 2.0.7.
- Made it so that the gpEAGeneralAllocator and gpEAGeneralAllocatorDebug variables are declared by default.

Version 1.09.01 (November 9, 2006)

Release Notes

- This version adds explicit support for Nintendo DS and adds bulk-build support for eaconfig.

Additions

- Added support for Nintendo DS to GeneralAllocator / GeneralAllocatorDebug. Thanks for Idries Hamadi for implementing this.
- FixedAllocator now has a Reset function. This function unilaterally clears the container and restores it to a newly initialized state.
- Added disabling of VC++ compiler warning C4748, which relates to the /GS compiler option in a release build. There are no existing cases of this warning in user's builds, and there won't likely ever be, as people generally don't use /GS with optimized builds.
- Added disabling of VC++ compiler warning C4740.
- Added "bulk-build" (a.k.a. "unity build") support to the .build file.

Bug Fixes

- <none>

Changes

- Moved the change list from the root directory .txt file to this doc/Changes.html file.

Version 1.09.00 (September 18, 2006)

Release Notes

- Due to the bug fix regarding GetBlockInfoForChunk, heap reports which labelled internal blocks as kBlockTypeAllocated will now label then as originally intended: kBlockTypeInternal. User heap report code might be affected by this change.

Additions

- Added recognition of PPMALLOC_DLL in addition to EA_DLL in order to use PPMalloc as a DLL. EA_DLL is a global define that causes everything to be built and used as DLLs. However, the user may want to set just PPMalloc to be built and used as a DLL.
- GeneralAllocatorDebug's debug data reading function has been moved from its protected space to public space as GetDebugDataStatic / SetDebugDataStatic.

Bug Fixes

- Fix bug in GeneralAllocatorDebug which misassigned the value for kDebugDataIdAllocator.
- Fixed bug in GeneralAllocator::GetBlockInfoForChunk whereby chunks returned to the user during a heap report would not be labelled as 'kBlockTypeInternal' when the block was internal.
- Fix for assert regarding page size that would occur on Xenon if you exhausted system memory.
- EAAllocationRecorder.h fixed to properly deal with the case whereby PPM_ENABLED = 0.
- FixedAllocator fixed to deal with the case whereby the user species an object count of just zero or one. User's don't do this in practice, but FixedAllocator would crash or corrupt memory if they did.
- Fix for ReportNext/GetBlockInfoForChunk to rectify case whereby blocks that were memory-mapped + aligned would have their reported pointer values be incorrect. A result of this was that TraceAllocatedMemory would think a pointer was bad when it wasn't and would generate a bogus assert.
- Fix for GeneralAllocator/GeneralAllocatorDebug not working with GCC strict pointer aliasing assumptions. Previously, you needed to compile with -fno-strict-aliasing in order for GeneralAllocator to compile correctly. This change fixes the known existing incompatibilities with strict pointer aliasing. However, more testing will need to be done to verify that all such pointer aliasing issues are resolved.

Changes

- Modified GeneralAllocator::AssertionFailureFunctionDefault to force-break on more platforms.
- Converted some use of \t in the source code to four spaces; done for consistency.
- Split FixedAllocator<> into FixedAllocatorBase and FixedAllocator<>. FixedAllocatorBase is a generic non-templated base for FixedAllocator<>. FixedAllocator<> is now nothing but a simple pass-through template with just two inline functions (ctor and Init).
- Added a small item to GeneralAllocator::Shutdown(). When tracing allocated memory (i.e. leaks), it now prints the allocator name with the allocation trace.
- The Xenon callstack reading functionality now can work in a shipping release build; it no longer relies on xbdm functionality, which is not allowed in a shipping build.
- Modified GeneralAllocatorDebug::ValidateHeap so that it uses a local SnapshotImage struct to do its heap report instead if using heap memory to do it.

Version 1.08.00 (April 10, 2006)

Additions

- Added explicit support for the new Nintendo Revolution (EA_PLATFORM_REVOLUTION)Added explicit support for the new Nintendo Revolution (EA_PLATFORM_REVOLUTION).
- Added Win64 / x86-64 support, including a unit test project.

Bug Fixes

- Removed EA::Allocator:: explicit qualifier from EASystemAllocator. GCC 4.x seems to have a problem with it.

Changes

- Made all internal header references be relative to the header root instead of the header file doing the #include. Some compilers (e.g. Metrowerks) don't support implicit relative header includes.

Version 1.07.00 (February 15, 2006)

Release Notes

- Thanks to Henry Goffin for finding and fixing various bugs that were fixed in this version, particularly those relating to mapped memory.

Additions

- Added GeneralAllocator::SetInitCallback, which is a simple implementation of the popularly requested mechanism to allow users to detect the set of existing allocator instances. This mechanism is fairly lightweight.
- Added AsInterface, which is a complement to SetInitCallback and which allows the user to detect whether a given GeneralAllocator is a GeneralAllocator or its subclass GeneralAllocatorDebug. This is useful for automated tools that want to identify and use heaps dynamically. This mechanism is trivially lightweight.
- Added Get/SetName, which is a complement to SetInitCallback and which allows the user to identify an allocator by name. This is useful for automated reporting tools so that they can report on heaps by name. This mechanism is trivially lightweight.
- Added the following FAQ entries:
  - How do I debug heap corruption problems?
  - Why use a heap manager on XBox 360, PS3 and PC when they have a hardware MMU?
  - Is GeneralAllocator deterministic?
  - How do I prevent users from calling global malloc and new?
  - I am getting a linker error regarding gpEAGeneralAllocator.
  - The Windows task manager is showing different memory stats than GeneralAllocatorDebug.
- Added documentation to the ValidateHeap function in EAGeneralAllocator.h.
- Added mpCore to GeneralAllocator::BlockInfo, so now you can tell which core block an allocation came from while doing heap reports.
- Added GeneralAllocator::SnapshotImage struct definition, in order to assist the user in defining a scratch buffer for heap traces. The user is not forced into using SnapshotImage, as the user may have a better source of scratch memory.
- Added example usage documentation to various functions in GeneralAllocatorDebug.

Bug Fixes

- Fixed a compiler warning under PS3 related to an unused variable.
- Fixed a bogus assert under PS3 related to expected 'chunk' size.
- Fixed a bogus assert under Win32 related to core resizing.
- GeneralAllocatorDebug::ValidateAddress bug fixes: In one case it could give a false negative when the pointer validation map is disabled. Also, it didn't check for the possibility of mapped memory. Both of these have been fixed.
- Fixed bug in GeneralAllocator::TakeSnapshot whereby when the user supplies a block of memory to use for the snapshot, the bytes before that memory might be stomped.
- Fixed documentation error in GeneralAllocatorDebug.h whereby it said that kDebugDataIdAllocationCount begins at zero, whereas in reality it begins at one.
- Fixed bug in GeneralAllocator::ReportNext whereby it was reporting internal chunks when the user didn't specify kBlockTypeInternal.
- Fixed bug in GeneralAllocatorDebug::AllocatorFree whereby it would erroneously assert that heap validation failed.
- Fixed bug in GeneralAllocatorDebug::ValidateHeap whereby the validation of a mapped memory chunk could misread the chunk pointer.
- Fixed bug in GeneralAllocator::MallocAlignedInternal whereby the mnPriorSize of mapped memory chunks (as opposed to regular chunks) was not being set.
- Fixed bug in GeneralAllocator::CheckMMappedChunk whereby the pMMappedChunk was incorrect.
- Fixed bug in GameCube GeneralAllocatorDebug's GetCallStack function which would misread the stack.
- Fixed bug whereby if you used GeneralAllocator but not GeneralAllocatorDebug and you called GeneralAllocator::DescribeChunk, it wouldn't append a newline (as it was implicitly assuming that the user was using GeneralAllocatorDebug, which would append it).
- Fixed bug in GeneralAllocatorDebugWin32's DescribeData() (which is currently an unused and undocumented utility function) to deal with the user supplying too small of a buffer.

Changes

- Updated the code to be compatible with PS3 SDK v050 (the newest as of this writing).
- GeneralAllocator::ValidateAddress used to return bool. Now it returns void* instead. It is essentially backwards compatible, as a NULL return value means the same thing as false from before. The new version merely provides additional information.
- Modified GeneralAllocatorDebug::Malloc() to use less stack space. It turns out that the PS3 implements some system callbacks in such a way that they give you rather little stack space to work with. This is an attempt to help deal with this limitation.
- Made a few GeneralAllocatorDebug functions const where they weren't previously.
- Increased the size of the temp buffer used by Win32 DescribeCallStack.
- Increased kDefaultTrimThreshold from 128K to 256K.

Version 1.06.00 (November 7, 2005)

Additions

- <none>

Bug Fixes

- Fixed the time calculation code in GeneralAllocatorDebug to work with PS3 SDK 040 and later.
- Fix for bogus assert that could have occurred during GeneralAllocatorDebug::Realloc. The code was executing fine, but there was an assert that mistakenly though things weren't fine.

Changes

- Removed TestSpeed.dsp/dsw. These are VC6 projects which are of no use to us. Similarly, removed TestGeneralAllocator PS3 make files, which are of no use any more.
- Disabled compiler warnings under VC++ / XBox 360 caused by recent versions of xtl.h which cause warnings. Only xtl.h-generated warnings are disabled.
- Some unnecessary build configurations were removed from the Xenon vcproj-based TestGeneralAllocator unit test project.

Version 1.05.00 (September 21, 2005)
Additions

- StackAllocator now has an option to use named allocations. This is useful for debugging as it allows you to recognized allocations in your general heap that come from a StackAllocator.
- StackAllocator bookmarks are more flexible and efficient now. Functionality should be entirely backward compatible. Users are no longer limited to a fixed number of bookmarks.
- kHookTypeCoreAlloc / kHookTypeCore free hooks are now available. These are useful for setting memory protection flags on core memory of a heap, for example.
- CircularAllocator.cpp added to examples directory. This is a demonstration of how to implement a FIFO allocator, as opposed to StackAllocator (or linear allocator) which is a LIFO allocator.
- Added a comment to every assert in GeneralAllocator.cpp and GeneralAllocatorDebug.cpp explaining what the assert means to the user. This was done because some users were complaining that an assert would fail and the didn't know how to interpret. In practice, when an assert fails it is almost always due to the user corrupting the heap, but we put explanations for them in the source code to assure the user.
- GeneralAllocatorDebug::ValidateHeap: Added an additional validation test.
- Added a few FAQ entries:
  How do I take advantage of large pages in Windows or XBox 360?
  How can I debug memory leaks?
- Updated documenation for the ReportHeap function.
- Added example code in the examples directory for how to do a page-protection memory error-detecting allocator.
- GeneralAllocator HookInfo now has a GeneralAllocator* pointer so that the user doesn't have to use the pContext parameter for this purpose.
- GeneralAllocatorDebug allocation metrics now have:
  mnAllocationCountMax; // High water mark of concurrent allocation count.
  mnAllocationVolumeMax; // High water mark of concurrent allocation volume.
- Added 'bool bNetSize' argument to GeneralAllocator::GetBlockSize in order to make user-level block size calculations reflect net memory usage better.
- kAllocationFlagPerm defined as a synonym for kAllocationFlagHigh. It seems that despite the documentation saying that high means permanent, there are a number of users that are used to thinking of high as being temporary and didn't notice the documentation for kAllocationFlagHigh.

Bug Fixes

- Moved some mutex-using code to within #ifdef PPM_THREAD_SAFETY_SUPPORTED.
- Mutex protection added for GetLargestFreeBlock, GetUsableSize and GetBlockSize.
- HookFuncton fixed to be spelled HookFunction, with backwards compatibility kept.
- kAllocationFlagMMap now lets you ignore heap restrictions on mapped memory counts and sizes.
- Switched some usage of (char*) casts to (uintptr_t) in order to prevent possible compiler warnings.
- GeneralAllocatorDebug will now clear its delayed free list if memory becomes exhausted.
- Fixed bug in Win32 call stack mechanism whereby it could shut down before the user was finished with it. It now allows the user to explicitly init and shut down the callstack mechanism. The problem occured if the user had memory leaks and they had GeneralAllocator explicitly set to shutdown after other modules.
- Fixed a GeneralAlloatorDebug bug whereby the pointer validation feature would generate bogus asserts under some configuration settings.
- Fixed bug in GeneralAllocatorDebug whereby ValidateAddress could recurse infinitely if the bPointerIsAllocation was set to false.
- GeneralAllocator fixed bug whereby 4 bytes more than the user requested could be allocated if the allocation is re-tryed after heap exhaustion and user-replenishment.

Changes

- Converted all header and source files to 4 spaces per indent instead of 3.

Version 1.04.00 (June 08, 2005)

Additions

- PS3 (PlayStation 3) PU and SPU support. This functionality has not been fully tested yet and may require some maintenance in the future. However, the unit tests for GeneralAllocator and GeneralAllocatorDebug succeed.
- kAllocationFlagMMap added as per an identified need for Xenon and PC platforms.
- More FAQ entries added, based on user feedback.
- StackAllocator Reset function added. It clears allocations and bookmarks.
- Added IsAllocationHigh to GeneralAllocator, as there was no means of telling a high from a low block.

Bug Fixes

- Robustified GetCallStack() in EAGeneralAllocatorDebugPS2.cpp to deal with the user having a different crt0.s file. This change was implemented by Simon Everett.
- Fixed bug in GeneralAllocator.cpp whereby if the user defined PPM_THREAD_SAFETY_SUPPORTED to be zero (i.e. disabled the support of threading) there would be compiler errors due to code that references some variables.
- Fixed bug in GeneralAllocatorDebug whereby if you exhausted the heap and had pointer validation enabled it would crash or report the heap as corrupted when it really wasn't. The problem was that some calls to AllocatorMalloc weren't being checked for their return value in GeneralAllocatorDebug.
- Fixed bogus assert in GeneralAllocatorDebug which was recently introduced (didn't exist in at least v1.0 and v1.1) which would occur if pointer validation and delayed frees were enabled at the same time.

Changes

- Builds as a Framework 2 package using eaconfig
- Class EA::Allocator::GeneralAllocatorInterface has been removed from the built library. If you want to use that class, it will be necessary to modify the library buildfile to build class the source file eaallocatorinterface.cpp. This change was done so next-gen titles do not need to use the Allocator package in their build process. Next-Gen titles should be using the ICoreAllocator interface for memory management.

Version 1.03.01 (Mar. 11, 2005)
Additions

- <none>

Bug Fixes

- On console platforms, if you ran out of memory and had some system memory available to allocate, but not enough system memory for how much you want, GeneralAllocator could in some cases would allocate the insufficient amount of system memory but report success. This could affect debug/development builds, but not release/shipping builds. The bug only manifests if all memory has become exhausted, so in practice the application would usually crash anyway.
- Robustified the chunk describing mechanism. It should be safe against overflows regardless of how big the chunk tag data is or how small the passed in description buffer is. The chunk describing mechanism has also been made a little more efficient.
- Robustified GetChunkIsFenceChunk to deal with user passing in a bad pointer.

Changes

- <none>

Version 1.3.0 (equivalent to 1.03.00) (Jan. 12, 2005)

Additions

- EA::Allocator::GetCallStack working again on the Xenon platform.
- Added detailed documentation for the Malloc and Free functions. Some users have not been sure about some things, such as what happens if you Malloc zero bytes.
- GeneralAllocatorDebug now enables pointer validation by default for PPM_DEBUG >= 2. Based on the design and documentation of PPM_DEBUG, this pointer validation would be expected. The user can always disable it, but the user probably wouldn't want to.
- ReportHeap and TakeSnapshot now allow you to filter away internal blocks. This allows heap reporting functions to ignore internal blocks. See the kBlockTypeInternal enumeration in class GeneralAllocator.

Bug Fixes

- Added line to GeneralAllocatorDebug::Malloc to check for integer overflow. If the user tried to allocate something 4GB of memory, this would catch the error. GeneralAllocator was already protected against such things.
- A typo in GeneralAllocatorDebug::DoFailureNotification was causing the message buffer to not show as much as most users would like and as much as was intended. It has been changed to the intended value.
- StackAllocator::MallocAligned fixed to obey minimum alignment expectations.
- StackAllocator::Malloc fixed to deal with the (unusual) case of address overflow.

Changes

- Stack reporting code for PS2 replaced with version submitted by Simon Everett. The new version is more flexible and more reliable. It is based on code that has been in production at EARS for some time.
- Macro for determining whether to create export symbols has been changed from _DLL to EA_DLL. This macro is supplied by tlconfig when a DLL is being built. _DLL is defined by the compiler when /MD or /MDd is passed on the compiler command line.

Version 1.2.0 (equivalent to 1.02.00) (Nov. 3, 2004)

Additions

- GetLargestFreeBlock function added to GeneralAllocator class. Refer to documentation for details.
- PPMMutexGetLockCount function added. Refer to documentation for details.
- PPMalloc is now available as a DLL. To build it, set a property called Dll to true. The DLLs and PDBs will be placed in ./bin/pc and the import library will be placed in ./lib/pcdll.
- GetVersion and CheckVersion functions added to verify that the correct version of the library has been loaded by the O/S (in the case of a DLL) or linked (in the case of a static library).

Bug Fixes

- A bug in GeneralAllocator::ChunkMatchesLowHigh has been fixed. This allows better allocation during very low memory conditions and provides for higher performance under some conditions.
- A bug has been fixed in GeneralAllocator::AddCore for when the user specified that they wanted new core of a given size but didn't specify an actual pointer to core.

Changes

- Updated default tlconfig dependency to 1.00.12.

Version 1.1.0 (equivalent to 1.01.00) (Aug. 24, 2004)

Bug Fixes

- A compilation bug for EA_PLATFORM_UNIX has been fixed (see change list #23233).
- A MSVC/Win32 code generation bug has been worked around (see change list #21327, GeneralAllocator::Shutdown).
- A bogus assert about memory fills has been fixed (see change list #21516, MallocAlignedInternal).
- A Win32 bug related to core trimming has been fixed (see change list #21497, GeneralAllocator::TrimCore).
- A bug in GeneralAllocatorDebug::kDebugDataIdAllocationCount usage has been fixed.

Changes

- Updated default tlconfig dependency to 1.00.10.
- Warnings 4525 and 4526 are not disabled on PC, Xbox, and Xenon any longer.
- Documenation has been enhanced (multiple change lists).
- PPM_DEBUG_FILL setting now available for better control over internal consistency checking (change list #23511).
- PPM_DEBUG levels have been modified so that PPM_DEBUG = 1 has higher performance but does less internal checking; you can use PPM_DEBUG = 2+ to obtain more automatic internal checking. Also, PPM_DEBUG levels are now explained in detail in the documentation (change list #23511).
- The GetBlockSize function has been added (change list #22415).
- AllocationRecorder now has thread safety built-in (change list #21497).
- GeneralAllocatorDebug guard fills have been improved (change list #23433).
- GeneralAllocatorDebug records the minimum supported alignment instead of zero when the user specifies an alignment of zero (change list #22689).
- GeneralAllocatorDebug::SetFillValues can now be called at any time and not only before the first allocation has occurred (change list #22415).
- GeneralAllocatorDebug's data map is disabled unless explicitly enabled.
- GeneralAllocatorDebug's metrics tracking is disabled unless explicitly enabled.
- GeneralAllocator now lets you explicitly clear the cache with ClearCache().

Version 1.00.00 (June 8, 2004)

Release Notes

- Initial public release.

End of document