Why use GD paint to destroy resources?

Source: Internet
Author: User
Keywords Php c mysql
MySQL shutdown (also counted as a kind of destruction) is the connection,
GD destroys the canvas.

MySQL connection is a process, what is GD's drawing? Memory?
Why is the canvas particularly resource-intensive? What part of the resource is consumed? Cpu? Memory? Or the other?

I want to know a friend to give a little instruction thank you

Reply content:

MySQL shutdown (also counted as a kind of destruction) is the connection,
GD destroys the canvas.

MySQL connection is a process, what is GD's drawing? Memory?
Why is the canvas particularly resource-intensive? What part of the resource is consumed? Cpu? Memory? Or the other?

I want to know a friend to give a little instruction thank you

1.MySQL connection is a thread, not a process
The client initiates a connection to the MySQL server,mysql server listener process, listens to the new request, and then MySQL assigns it a new thread to process the request. From the beginning of the connection, the CPU will give it a certain thread stack, then authenticate the user, establish the context information, the final request is completed, close the connection, and release the resources, in the case of high concurrency, the system would bring enormous pressure, can not guarantee performance. So, MySQL through the thread cache is to implement thread reuse, reduce this part of the consumption, a connection disconnected, does not destroy the thread that hosts it, but put this thread into the thread buffer, and in a suspended state, the next time a new connection arrives, First go to the thread buffer to find out if there are idle threads, if any, then use it, and if not, create a new thread.

2.GD release, is free memory
After the image is output, the contents of the canvas are no longer useful. For the sake of saving system resources, it is necessary to clear all the memory resources occupied by the canvas in time.

Simply put, the resources GD consumes have at least memory.
You know, the image relative to the text, the stored information is massive, very cost memory.
When you start using GD, you allocate a lot of memory to the canvas.
When you are finished, this part of the memory is useless, of course, to release.

As for the specific GD will use what resources, this and GD implementation related.

Like file open/close, database connection/disconnect, memory request/release and so on, after the use of resources, develop a good habit of release.

  • 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.