Home > Backend Development > PHP Tutorial > 既是HTTP是无状态协议,mysql_close还有必要么

既是HTTP是无状态协议,mysql_close还有必要么

WBOY
Release: 2016-06-13 12:48:48
Original
972 people have browsed it

既然HTTP是无状态协议,mysql_close还有必要么?
既然是查一次连接一次,为什么还要关闭连接呢?

还有上传图片,有个imagedestroy函数释放内存,如果我不释放呢,机器内存就一直傻乎乎让图片占着直到死机吗?


------解决方案--------------------
你的网站的访问者(他的电脑或手机)和你的web server(比如apache)之间的连接是http,

mysql_connect建立的是你的web server和你的mysql server之间的连接(即使它们在一个机器上)

如果忘记关闭数据库连接, 该连接会保持直到你close了或者该次请求的php运行完毕...

如果没有imagedestroy, 该内存会被占用直到你destroy或者运行结束.(我不明确会不会被垃圾回收,如果该图片的资源引用数为0)
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template