A hand to help see a piece of code, why memory exhaustion

Source: Internet
Author: User
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!
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.