fix potential undefined behavior when memory_limit = -1