Hacker News new | ask | show | jobs
by IngvarLynn 1173 days 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.
2 comments

The 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).
Every quote in a jsonstring requires backslashes. This is geometric explosion. You're assuming very simple state objects.