Why is the memory exhausted?

Source: Internet
Author: User
Why is the memory exhausted?
$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);}


If we need to test the data, we need to write 0.5 billion pieces of data into 500 mysql tables and run the code directly using the php command. why is the memory exhausted?

Thank you!


Reply to discussion (solution)

I sent this before. I 'd like to pick it up!

Http://bbs.csdn.net/topics/390121151

No, but it's hard to say if your hard disk space is insufficient.
At least insert_table should be used to determine whether insertion is successful

I do not know the get_hash_table algorithm, but the data span of $ rand_uid is 5000000.

Batch execution to release memory

No, but it's hard to say if your hard disk space is insufficient.
At least insert_table should be used to determine whether insertion is successful

I do not know the get_hash_table algorithm, but the data span of $ rand_uid is 5000000.

Thank you for your reply!

The disk space is large enough, and I/O is normal.

Batch execution to release memory


The key is that I don't know which part consumes memory!

Take a look at it using the memory_get_usage function.


Batch execution to release memory


The key is that I don't know which part consumes memory!

I personally said that this code segment is basically no different from the endless loop, that is, it will be executed, and SLEEP in the loop body to see it

You 'd better paste both get_hash_tableh and insert_table!



I read the disk I/O. this is the cause.

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.