aximbigfan Posted September 29, 2008 Share Posted September 29, 2008 Sorry if this is the wrong forum. I figured this doesn't really figure into core hacking. Anyway, for a minute, lets ignore good coding practices, and assume I have a script that uses up 40MB of memory, and the device it is running on only has 32MB. what will happen? Lets also assume that resource limiters in php.ini are all disabled. The reason I ask, is I have a PHP script that goes through a folder packing up files into an array, then serializing it and putting it in a file. the script is running on an ARM9 Hp MediaVault MV2120 with a 500GB hdd. Since there is an HDD, will PHP create a page file or something? Thanks, Chris Link to comment https://forums.phpfreaks.com/topic/126230-memory-managment-in-php/ Share on other sites More sharing options...
ratcateme Posted September 29, 2008 Share Posted September 29, 2008 i had a script that use heaps of memory and thought of something like that but after a few days of googling i found nothing in your case what if you looked at checking the size of the array and when it got to big serialize it and output it to the file followed by some marker then you wont go over the max memory. then just append the file every time you go over again so it ends up with a number of arrays in it. Scott. Link to comment https://forums.phpfreaks.com/topic/126230-memory-managment-in-php/#findComment-652762 Share on other sites More sharing options...
aximbigfan Posted September 29, 2008 Author Share Posted September 29, 2008 I forgot to mention that it is also restoring files, which means it gets one giant serialized array which it sorts through. I have optimized it as much as i can with limited the amount of variables created, and unsetting when i am not using stuff. Even then, that is a bandage fix. The real fix is for PHP to use HDD space as RAM. What does PHP do if it runs out of RAM? Does it create a temp file and use that? Chris Link to comment https://forums.phpfreaks.com/topic/126230-memory-managment-in-php/#findComment-652768 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.