I wonder how you come up with this maximum size? Every server has its exclusive available memory size at different moments. Could 256*1024 be too large or small in different cases?

This is the chunk of code I put in before for memory calculation: https://github.com/atutor/AChecker/blob/master/checker/index.php#L196-L200. Apparently, this calculation didn't cover all scenarios since we still run into the memory issue sometimes. :) But this code illustrates my thoughts: due to the variability of the available memory, rather than relying on a human to blindly guess how much space is needed, I did some monitoring which ended up with a formula that 1K of input html roughly requires 160K memory to process it (https://github.com/atutor/AChecker/blob/master/include/classes/Utility.class.php#L198). However, as what the reality proves, this is not true all the time since the number of html tags in this 1K and how simple html dom library handles those tags are also factors for needed memory.

Your thoughts?