Master Help to see a piece of code, why memory exhaustion
$i =-1;
while ($i + + < 495000000) {
$rand _uid = rand (100000000,105000000);
$rand _fuid = rand (100000000,999999999);
$tab _name = get_hash_table (' Friends ', $rand _uid);
$up _array = Array (
' UID ' = $rand _uid,
' Fuid ' = $rand _fuid
);
Insert_table ($tab _name, $up _array,1);
}
Need to test data, to write 500 million data into 500 MySQL tables, directly executed with the PHP command code, why is memory exhausted?
Thanks a lot!
Share to:
------Solution--------------------
No, but if you're running out of hard disk space, you're not going to be able to say
At least insert_table should determine if the insert succeeds
Unknown to the get_hash_table algorithm, but the data span of the $rand _uid is 5000000
------Solution--------------------
Batch execution, freeing memory
------Solution--------------------
Take a look at the Memory_get_usage function
Reference:
Quote: Reference:
Batch execution, freeing memory
The point is I don't know which part consumes the memory!
------Solution--------------------
The individual says that this code is basically no different from the dead loop, that is, he will execute it, and sleep in the loop body to see
------Solution--------------------
You'd better post Get_hash_tableh and insert_table!