Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ jobs:
VS_GENERATOR_TOOLSET: ${{ matrix.VS_GENERATOR_TOOLSET }}
SYSTEM_PYTHON: ${{ matrix.SYSTEM_PYTHON }}
UTF8_TEST_CWD: ${{ matrix.UTF8_TEST_CWD }}
SENTRY_TEST_OOM_LIMIT: "4095" # ~4GB, to speed up OOM tests

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
Expand Down
24 changes: 24 additions & 0 deletions examples/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,30 @@ trigger_stack_overflow()
static void
trigger_oom(void)
{
#ifdef SENTRY_PLATFORM_WINDOWS
// Optionally limit process memory to trigger OOM faster.
// Set SENTRY_TEST_OOM_LIMIT to the limit in MiB (e.g. "8192" for 8GB).
// Without this, OOM exhausts all virtual memory which can take minutes.
// Note: a Job Object limit only constrains user-mode allocations and
// does not exhaust kernel pool memory like a real system-wide OOM would.
const char *oom_limit = getenv("SENTRY_TEST_OOM_LIMIT");
if (oom_limit) {
unsigned long long limit = strtoull(oom_limit, NULL, 10) * 1024 * 1024;
if (limit > 0 && limit <= SIZE_MAX) {
HANDLE job = CreateJobObjectW(NULL, NULL);
if (job) {
JOBOBJECT_EXTENDED_LIMIT_INFORMATION info = { 0 };
info.BasicLimitInformation.LimitFlags
= JOB_OBJECT_LIMIT_PROCESS_MEMORY;
info.ProcessMemoryLimit = (size_t)limit;
SetInformationJobObject(job, JobObjectExtendedLimitInformation,
&info, sizeof(info));
AssignProcessToJobObject(job, GetCurrentProcess());
}
}
}
#endif

size_t count = 1024;
for (;;) {
void *p = malloc(count);
Expand Down
Loading