11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_cirequire('../common');
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci// Test that huge objects don't crash due to exceeding the maximum heap size.
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst util = require('util');
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci// Create a difficult to stringify object. Without the artificial limitation
101cb0ef41Sopenharmony_ci// this would crash or throw an maximum string size error.
111cb0ef41Sopenharmony_cilet last = {};
121cb0ef41Sopenharmony_ciconst obj = last;
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_cifor (let i = 0; i < 1000; i++) {
151cb0ef41Sopenharmony_ci  last.next = { circular: obj, last, obj: { a: 1, b: 2, c: true } };
161cb0ef41Sopenharmony_ci  last = last.next;
171cb0ef41Sopenharmony_ci  obj[i] = last;
181cb0ef41Sopenharmony_ci}
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ciutil.inspect(obj, { depth: Infinity });
21