Need an array-like structure in PHP with minimal memory usage

后端 未结 8 2208
星月不相逢
星月不相逢 2020-12-23 02:02

In my PHP script I need to create an array of >600k integers. Unfortunately my webservers memory_limit is set to 32M so when initializing the array the script a

8条回答
  •  借酒劲吻你
    2020-12-23 03:00

    A PHP Judy Array will use significantly less memory than a standard PHP array, and an SplFixedArray.

    I quote "An array with 1 million entries using regular PHP array data structure takes 200MB. SplFixedArray uses around 90 megabytes. Judy uses 8 megs. Tradeoff is in performance, Judy takes about double the time of regular php array implementation."

提交回复
热议问题