Fix memory issue on cache_size larger than 2048