4 ms·
Assuming 3 backslashes per iteration, one iteration per second - it would take 16 years to get to 1.5GB. This code problem looks deeper to me.
by IngvarLynn 3y ago
Assuming 3 backslashes per iteration, one iteration per second - it would take 16 years to get to 1.5GB. This code problem looks deeper to me.
- cyanydeez 3y agoEvery quote in a jsonstring requires backslashes. This is geometric explosion. You're assuming very simple state objects.
- NieDzejkob 3y agoThe growth is exponential - each backslash becomes two in the next iteration. Thus after n iterations we have 2^n - 1 backslashes, and we only need 30 iterations to hit a gigabyte (and that's assuming only one quotation mark in the original JSON).