A ratio limit is a hueristic.<p>There <i>is</i> an upper-limit to how much <i>information</i> you can compress into a given space. (Note that we may want to write a pathological program that is very small and allocates a lot of information-free memory. But that&#x27;s not decompression.)<p>If we accept the premise then we can look at another approach to solving this problem, once and for all! I like examining memory allocation because it&#x27;s so general. But there may be another way. We can examine the input to estimate compression ratio.<p>The problem here is that image decompression is apparently giving strangers the ability provide an arbitrary N and say &quot;Please loop N times and&#x2F;or allocate N bits&quot;. A modern CPU is overwhelmed by an N 12 bits long or longer. This is a root cause of many problems! You know, I&#x27;m going to go out on a limb here and make a bold assertion: I assert there is a very safe upper bound on the decompression ratio, and that for any real algorithm <i>you can indeed examine the input to determine whether N exceeds your allowable threshold</i>. 10x might be a bit low (although I doubt it) so let&#x27;s be generous and say 100x. (Which seems crazy. Nothing that I know of, not even text, compresses that well.) This means that I believe that any image format, for example, has a trivially calculable N (for example, width*height in pixels). I would argue that in the general case (unless you are doing some sort of compsci research) the image file should be related to N. That is if the image is 10 bits wide, 10 bits high, we should expect a roughly 20bit file-size.