当前位置:网站首页>Force freeing memory in PHP
Force freeing memory in PHP
2022-07-03 02:51:00 【fyin1314】
problem :
In a PHP program, I sequentially read a bunch of files (with file_get_contents ), gzdecode them, json_decode the result, analyze the contents, throw most of it away, and store about 1% in an array. stay PHP In the program , I read a pile of files in turn ( Use file_get_contents ), gzdecode They do json_decode Proceed with the result json_decode , Analysis content , Throw away most of the content , Then, about 1% The contents of are stored in an array .
Unfortunately, with each iteration (I traverse over an array containing the filenames), there seems to be some memory lost (according to memory_get_peak_usage , about 2-10 MB each time). Unfortunately , Every iteration ( I iterate through the array containing file names ), It seems that some memory will be lost ( according to memory_get_peak_usage , About every time 2-10 MB).I have double- and triple-checked my code; I checked my code twice and three times ;I am not storing unneeded data in the loop (and the needed data hardly exceeds about 10MB overall), but I am frequently rewriting (actually, strings in an array). I don't store unnecessary data in the loop ( And the data required is almost no more than 10MB), But I often rewrite ( It's actually a string in an array ).Apparently, PHP does not free the memory correctly, thus using more and more RAM until it hits the limit. obviously ,PHP Memory is not released correctly , Therefore, more and more RAM, Until the limit is reached .
Is there any way to do a forced garbage collection? Is there any way to force garbage collection ?Or, at least, to find out where the memory is used? perhaps , At least , Find out where the memory is used ?
Solution :
Reference resources : https://stackoom.com/en/question/AKPq边栏推荐
- 错误Invalid bound statement (not found): com.ruoyi.stock.mapper.StockDetailMapper.xxxx解决
- JMeter performance test JDBC request (query database to obtain database data) use "suggestions collection"
- 二维格式数组格式索引下标连续问题导致 返回json 格式问题
- Classes and objects - initialization and cleanup of objects - constructor call rules
- How to implement append in tensor
- Pytest (6) -fixture (Firmware)
- I2C subsystem (II): I3C spec
- SQL Server Query spécifie la structure de la table
- 疫情当头,作为Leader如何进行代码版本和需求开发管控?| 社区征文
- Deep reinforcement learning for intelligent transportation systems: a survey paper reading notes
猜你喜欢

Add automatic model generation function to hade

I2C 子系统(一):I2C spec

Yiwen takes you to know ZigBee

Today, it's time to copy the bottom!

Super easy to use logzero

Sqlserver row to column pivot

Build a private cloud disk cloudrev

The Linux server needs to install the agent software EPS (agent) database
![[fluent] JSON model conversion (JSON serialization tool | JSON manual serialization | writing dart model classes according to JSON | online automatic conversion of dart classes according to JSON)](/img/6a/ae44ddb090ce6373f04a550a15f973.jpg)
[fluent] JSON model conversion (JSON serialization tool | JSON manual serialization | writing dart model classes according to JSON | online automatic conversion of dart classes according to JSON)

From C to capable -- use the pointer as a function parameter to find out whether the string is a palindrome character
随机推荐
random shuffle注意
Source code analysis | layout file loading process
Kubernetes cluster log and efk architecture log scheme
How to change the panet layer in yolov5 to bifpn
I2C 子系統(四):I2C debug
[principles of multithreading and high concurrency: 1_cpu multi-level cache model]
xiaodi-笔记
你真的懂继电器吗?
Check log4j problems using stain analysis
[fluent] future asynchronous programming (introduction | then method | exception capture | async, await keywords | whencomplete method | timeout method)
Hcip137-147 title + analysis
Check log4j problems using stain analysis
Xiaodi notes
SQL statement
C language beginner level - pointer explanation - paoding jieniu chapter
Gbase 8C system table PG_ amproc
【翻译】具有集中控制平面的现代应用负载平衡
ASP. Net core 6 framework unveiling example demonstration [02]: application development based on routing, MVC and grpc
C语言中左值和右值的区别
sql server 查詢指定錶的錶結構