当前位置:网站首页>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边栏推荐
- leetcode540
- Basic operation of binary tree (C language version)
- Cancer biopsy instruments and kits - market status and future development trends
- HTB-Devel
- Can netstat still play like this?
- Deep learning: multi-layer perceptron and XOR problem (pytoch Implementation)
- The core idea of performance optimization, dry goods sharing
- Principle and application of database
- Kubernetes family container housekeeper pod online Q & A?
- Source code analysis | resource loading resources
猜你喜欢

Check log4j problems using stain analysis

HTB-Devel

Error invalid bound statement (not found): com ruoyi. stock. mapper. StockDetailMapper. XXXX solution

The Linux server needs to install the agent software EPS (agent) database

你真的懂继电器吗?

Pytest (6) -fixture (Firmware)

"Analysis of 43 cases of MATLAB neural network": Chapter 43 efficient programming skills of neural network -- Discussion Based on the characteristics of the new version of MATLAB r2012b

《MATLAB 神经网络43个案例分析》:第43章 神经网络高效编程技巧——基于MATLAB R2012b新版本特性的探讨

定了,就选它

【翻译】具有集中控制平面的现代应用负载平衡
随机推荐
Gbase 8C trigger (III)
Your family must be very poor if you fight like this!
Error when installing MySQL in Linux: starting mysql The server quit without updating PID file ([FAILED]al/mysql/data/l.pid
迅雷chrome扩展插件造成服务器返回的数据js解析页面数据异常
Gbase 8C trigger (I)
Global and Chinese ammonium dimolybdate market in-depth analysis and prospect risk prediction report 2022 Edition
C语言中左值和右值的区别
SQL Server Query spécifie la structure de la table
你真的懂继电器吗?
[C language] MD5 encryption for account password
【富瀚6630编码存录像,用rtsp服务器及时间戳同步实现vlc观看录像】
Gbase 8C function / stored procedure parameters (I)
[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)
Kubernetes cluster log and efk architecture log scheme
I2C 子系统(一):I2C spec
Deep Reinforcement Learning for Intelligent Transportation Systems: A Survey 论文阅读笔记
I2C subsystem (III): I2C driver
Today, it's time to copy the bottom!
Three. JS local environment setup
Summary of interview project technology stack