当前位置:网站首页>[PHP] PHP variable memory release
[PHP] PHP variable memory release
2022-06-30 00:25:00 【weixin_ forty-three million two hundred and twenty-four thousan】
adopt PHP memory_get_usage() Function to get the physical memory occupied by the current process , The comparison shows that :
1、unset() Function can free memory
2、 The local variables inside the function will be automatically released after the function is executed
Look at the code below :
<?php
echo __LINE__ . ' ' . memory_get_usage() . "\n"; // 36640
function a () {
$a = str_repeat("Hello", 4242);
echo __LINE__ . ' ' . memory_get_usage() . "\n"; // 36640
unset($a);
echo __LINE__ . ' ' . memory_get_usage() . "\n"; // 36640
}
a();
echo __LINE__ . ' ' . memory_get_usage() . "\n"; // 36640
#unset($a);
#echo memory_get_usage() . "\n"; // 36744
result :
2 --355056
6-- 379664
10-- 355088
14 --355088
The first column is the line number
Conclusion
It can be used in obvious places unset() Function to display the reclaimed memory , In scenarios with complex functions, memory can be reclaimed in the form of functions
边栏推荐
- Finding a job in 2022 is the "last lesson" for graduates
- vsftp 与 TFTP 与 samba 与 nfs 复习
- MySQL基础3
- 【UML】UML的几种关系(依赖-关联-聚合-组合-继承-实现)
- MySQL advanced 2
- JS的初步语法
- 学位论文的引用
- leetcode-1. 两数之和
- [graduation season 𞓜 advanced technology Er] employees who have worked for seven years do not want you to take another detour
- Vulnhub靶机-MoriartyCorp
猜你喜欢

数据中台的五个关键要素

Some specifications based on zfoo development project

SOFARegistry 源码|数据同步模块解析

SOFARegistry 源码|数据同步模块解析

JS draw polar color gradient

Sword finger offer II 037 Asteroid collision

关联性——典型相关分析

博途V16 更改PLC的型号和固件版本

Color space conversion in video tonemapping (HDR to SDR) (bt2020 to bt709, YCbCr, YUV and RGB)

Introduction to reptiles: data capture of Betta barrage, with 11 introductory notes attached
随机推荐
Label Troubleshooting: unable to open the marked image
How to seamlessly transition from traditional microservice framework to service grid ASM
云原生爱好者周刊:炫酷的 Grafana 监控面板集合
[advanced C language] file operation (II)
Introduction to reptiles: data capture of Betta barrage, with 11 introductory notes attached
固定资产管理系统多少钱,固定资产管理系统价格
有流量,但没有销售?增加网站销量的 6 个步骤
MySQL basics 1
Connection query of SQL Server database
网络方向哪个发展更好?数据通信工程师学习路线分享
MySQL基礎2
股票网上开户及开户流程怎样?还有,在线开户安全么?
[graduation season 𞓜 advanced technology Er] employees who have worked for seven years do not want you to take another detour
Sofaregistry source code | data synchronization module analysis
【编程题】迷宫问题
[advanced C language] string and memory function (II)
利用 CertBot 申请 Let’s Encrypt SSL 证书
Solr基础操作13
公司固定资产该哪个部门管理,一般公司固定资产怎么管理
Quick Pow: 如何快速求幂