File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -235,6 +235,7 @@ jobs:
235235 VS_GENERATOR_TOOLSET : ${{ matrix.VS_GENERATOR_TOOLSET }}
236236 SYSTEM_PYTHON : ${{ matrix.SYSTEM_PYTHON }}
237237 UTF8_TEST_CWD : ${{ matrix.UTF8_TEST_CWD }}
238+ SENTRY_TEST_OOM_LIMIT : " 4095" # ~4GB, to speed up OOM tests
238239
239240 steps :
240241 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
Original file line number Diff line number Diff line change @@ -384,6 +384,30 @@ trigger_stack_overflow()
384384static void
385385trigger_oom (void )
386386{
387+ #ifdef SENTRY_PLATFORM_WINDOWS
388+ // Optionally limit process memory to trigger OOM faster.
389+ // Set SENTRY_TEST_OOM_LIMIT to the limit in MiB (e.g. "8192" for 8GB).
390+ // Without this, OOM exhausts all virtual memory which can take minutes.
391+ // Note: a Job Object limit only constrains user-mode allocations and
392+ // does not exhaust kernel pool memory like a real system-wide OOM would.
393+ const char * oom_limit = getenv ("SENTRY_TEST_OOM_LIMIT" );
394+ if (oom_limit ) {
395+ unsigned long long limit = strtoull (oom_limit , NULL , 10 ) * 1024 * 1024 ;
396+ if (limit > 0 && limit <= SIZE_MAX ) {
397+ HANDLE job = CreateJobObjectW (NULL , NULL );
398+ if (job ) {
399+ JOBOBJECT_EXTENDED_LIMIT_INFORMATION info = { 0 };
400+ info .BasicLimitInformation .LimitFlags
401+ = JOB_OBJECT_LIMIT_PROCESS_MEMORY ;
402+ info .ProcessMemoryLimit = (size_t )limit ;
403+ SetInformationJobObject (job , JobObjectExtendedLimitInformation ,
404+ & info , sizeof (info ));
405+ AssignProcessToJobObject (job , GetCurrentProcess ());
406+ }
407+ }
408+ }
409+ #endif
410+
387411 size_t count = 1024 ;
388412 for (;;) {
389413 void * p = malloc (count );
You can’t perform that action at this time.
0 commit comments