Skip to content

Commit

Permalink
Zero offheap on commit on OSX
Browse files Browse the repository at this point in the history
For some reason OSX does not seem to zero memory on commit, unless it's
the first commit. For now, till we understand if there is a way to force
zero on subsequent re-commits, we will zero it explicitly.

Including zPTF as well, since we don't know how it will behave, even
if/when it adds support for commit/decommit/virtual-memory.

Signed-off-by: Aleksandar Micic <[email protected]>
  • Loading branch information
Aleksandar Micic authored and Aleksandar Micic committed Nov 26, 2024
1 parent 22a5046 commit 9e83ee1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gc/base/SparseVirtualMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ MM_SparseVirtualMemory::allocateSparseFreeEntryAndMapToHeapObject(void *proxyObj
void *sparseHeapAddr = _sparseDataPool->findFreeListEntry(adjustedSize);
bool success = MM_VirtualMemory::commitMemory(sparseHeapAddr, adjustedSize);

#if defined(OSX) || defined(OMRZTPF)
/* Most platforms will perform an implicit zero through the preceding commit. */
OMRZeroMemory(sparseHeapAddr, adjustedSize);
#endif /* defined(OSX) || defined(OMRZTPF)) */

if (NULL != sparseHeapAddr) {
_sparseDataPool->mapSparseDataPtrToHeapProxyObjectPtr(sparseHeapAddr, proxyObjPtr, adjustedSize);
} else {
Expand Down

0 comments on commit 9e83ee1

Please sign in to comment.