当前位置:网站首页>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边栏推荐
- Segmentation fault occurs during VFORK execution
- 疫情当头,作为Leader如何进行代码版本和需求开发管控?| 社区征文
- Gbase 8C trigger (I)
- I2C 子系统(三):I2C Driver
- Andwhere multiple or query ORM conditions in yii2
- Gbase 8C system table PG_ am
- Build a private cloud disk cloudrev
- [C语言]给账号密码进行MD5加密
- Process the dataset and use labelencoder to convert all IDs to start from 0
- Your family must be very poor if you fight like this!
猜你喜欢

What does "where 1=1" mean
![[Hcia]No.15 Vlan间通信](/img/59/a467c5920cbccb72040f39f719d701.jpg)
[Hcia]No.15 Vlan间通信

From C to capable -- use the pointer as a function parameter to find out whether the string is a palindrome character

Didi programmers are despised by relatives: an annual salary of 800000 is not as good as two teachers

Deep reinforcement learning for intelligent transportation systems: a survey paper reading notes

Joking about Domain Driven Design (III) -- Dilemma

SqlServer行转列PIVOT

从C到Capable-----利用指针作为函数参数求字符串是否为回文字符

vfork执行时出现Segmentation fault

Error invalid bound statement (not found): com ruoyi. stock. mapper. StockDetailMapper. XXXX solution
随机推荐
Joking about Domain Driven Design (III) -- Dilemma
Xiaodi notes
SQL statement
sql server 查詢指定錶的錶結構
Update and return document in mongodb - update and return document in mongodb
【Flutter】shared_ Preferences local storage (introduction | install the shared_preferences plug-in | use the shared_preferences process)
【翻译】后台项目加入了CNCF孵化器
tensorflow转pytorch笔记;tf.gather_nd(x,y)转pytorch
I2C subsystem (IV): I2C debug
leetcode540
Source code analysis | layout file loading process
Kubernetes family container housekeeper pod online Q & A?
Gbase 8C function / stored procedure parameters (I)
I2C subsystem (III): I2C driver
Gbase 8C system table PG_ auth_ members
The solution of "the required function is not supported" in win10 remote desktop connection is to modify the Registry [easy to understand]
《MATLAB 神经网络43个案例分析》:第43章 神经网络高效编程技巧——基于MATLAB R2012b新版本特性的探讨
左值右指解释的比较好的
Process the dataset and use labelencoder to convert all IDs to start from 0
迅雷chrome扩展插件造成服务器返回的数据js解析页面数据异常