K
K
Kirill Nesmeyanov2017-01-19 20:53:51
PHP
Kirill Nesmeyanov, 2017-01-19 20:53:51

How to catch a memory leak?

There is a data import script whose memory consumption graph looks like this:
89284495ff6f494798850cc9338395a7.png
Although the algorithm is built on coroutines (each mini-peak is a new iteration), there is clearly a leak somewhere (or rather, someone fills the memory with side data). The problem is that the language is php 7.1, i.e. no obsolete xprof and memprof. Ideally, I would like to get a snapshot of all primitive zval containers at the beginning and at the very end, because such things are 146% affected by filling an array or string with data.
Any ideas?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Dart, 2017-01-19
@gobananas

It's hard to wang without code. It seems that in each iteration either a new variable is created and then not removed, or an element is added to the array, processed somehow, then the next element and so the array grows over time.

A
Andrey Nikolaev, 2017-01-19
@gromdron

I looked at Dmitry's message and your comments - is it possible to find out the higher function that is above it? It's just logical that this piece of code will grow all the time, because There is a search of all values ​​and naturally the processing takes place at a higher level - you need to look there :)
UPD: And what did xdebug actually do not please?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question