+static void commitZeroPages(void* startAddress, size_t sizeInBytes)
+{
+ bool writable = true;
+ bool executable = false;
+#if OS(LINUX)
+ // In Linux, MADV_DONTNEED clears backing pages with zero. Be Careful that MADV_DONTNEED shows different semantics in different OSes.
+ // For example, FreeBSD does not clear backing pages immediately.
+ while (madvise(startAddress, sizeInBytes, MADV_DONTNEED) == -1 && errno == EAGAIN) { }
+ OSAllocator::commit(startAddress, sizeInBytes, writable, executable);
+#else
+ OSAllocator::commit(startAddress, sizeInBytes, writable, executable);
+ memset(startAddress, 0, sizeInBytes);
+#endif
+}
+