Skip to content

Commit

Permalink
Fix Bugzilla issue 24309 - Memory allocation failed on Azure pipeline
Browse files Browse the repository at this point in the history
ignore spurious out-of-memory errors, the test is about something else
  • Loading branch information
rainers authored and dlang-bot committed Feb 4, 2024
1 parent 90e32a7 commit ab45c77
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions druntime/src/core/internal/gc/impl/conservative/gc.d
Original file line number Diff line number Diff line change
Expand Up @@ -4988,24 +4988,34 @@ version (D_LP64) unittest
{
// only run if the system has enough physical memory
size_t sz = 2L^^32;
//import core.stdc.stdio;
//printf("availphys = %lld", os_physical_mem(true));
if (os_physical_mem(true) > sz)
size_t phys_mem = os_physical_mem(true);
if (phys_mem > sz)
{
import core.memory;
import core.exception;
GC.collect();
GC.minimize();
auto stats = GC.stats();
auto ptr = GC.malloc(sz, BlkAttr.NO_SCAN);
auto info = GC.query(ptr);
//printf("info.size = %lld", info.size);
assert(info.size >= sz);
GC.free(ptr);
GC.minimize();
auto nstats = GC.stats();
assert(nstats.usedSize == stats.usedSize);
assert(nstats.freeSize == stats.freeSize);
assert(nstats.allocatedInCurrentThread - sz == stats.allocatedInCurrentThread);
try
{
auto stats = GC.stats();
auto ptr = GC.malloc(sz, BlkAttr.NO_SCAN);
auto info = GC.query(ptr);
//printf("info.size = %lld", info.size);
assert(info.size >= sz);
GC.free(ptr);
GC.minimize();
auto nstats = GC.stats();
assert(nstats.usedSize == stats.usedSize);
assert(nstats.freeSize == stats.freeSize);
assert(nstats.allocatedInCurrentThread - sz == stats.allocatedInCurrentThread);
}
catch (OutOfMemoryError)
{
// ignore if the system still doesn't have enough virtual memory
import core.stdc.stdio;
printf("%s(%d): out-of-memory execption ignored, phys_mem = %zd",
__FILE__.ptr, __LINE__, phys_mem);
}
}
}
}
Expand Down

0 comments on commit ab45c77

Please sign in to comment.