当前位置:网站首页>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边栏推荐
- 《MATLAB 神经网络43个案例分析》:第43章 神经网络高效编程技巧——基于MATLAB R2012b新版本特性的探讨
- Matlab tips (24) RBF, GRNN, PNN neural network
- 定了,就选它
- sql server 查询指定表的表结构
- Getting started | jetpack hilt dependency injection framework
- Xiaodi notes
- sql server数据库添加 mdf数据库文件,遇到的报错
- Privatization lightweight continuous integration deployment scheme -- 01 environment configuration (Part 2)
- Strategy application of Dameng database
- C language beginner level - pointer explanation - paoding jieniu chapter
猜你喜欢

Segmentation fault occurs during VFORK execution

SQL statement

random shuffle注意
![ASP. Net core 6 framework unveiling example demonstration [02]: application development based on routing, MVC and grpc](/img/cb/145937a27ef08050a370d5a255215a.jpg)
ASP. Net core 6 framework unveiling example demonstration [02]: application development based on routing, MVC and grpc

HTB-Devel

I2C 子系统(一):I2C spec

错误Invalid bound statement (not found): com.ruoyi.stock.mapper.StockDetailMapper.xxxx解决

内存泄漏工具VLD安装及使用

I2C 子系统(三):I2C Driver

Installation and use of memory leak tool VLD
随机推荐
Your family must be very poor if you fight like this!
Kubernetes cluster log and efk architecture log scheme
sql server数据库添加 mdf数据库文件,遇到的报错
Concrete CMS vulnerability
Source code analysis | layout file loading process
Deep Reinforcement Learning for Intelligent Transportation Systems: A Survey 论文阅读笔记
Gbase 8C trigger (I)
Use cve-2021-43893 to delete files on the domain controller
I2C 子系統(四):I2C debug
定了,就选它
As a leader, how to control the code version and demand development when the epidemic comes| Community essay solicitation
Why choose a frame? What frame to choose
HTB-Devel
C语言中左值和右值的区别
random shuffle注意
The core idea of performance optimization, dry goods sharing
SQL statement
Gbase 8C system table PG_ auth_ members
I2C subsystem (II): I3C spec
[C language] MD5 encryption for account password