Overkill. We are dealing with file names here, and if they are long enough to exhaust all available heap space, this situation is messed up enough that throwing an Error is just fine.