BitOne / php-meminfo

PHP extension to get insight about memory usage
MIT License
1.08k stars 78 forks source link

Don't see memory leack in memory dump #54

Open Shkarbatov opened 6 years ago

Shkarbatov commented 6 years ago

Hi, I have memory leack in my workers.

I have done memory_get_usage() on each iteration: 50183840 91469968 95433592 99533688 103630880 107729448 .. 378392128

Also I have done memory dump by meminfo: meminfo_dump(fopen('/home/dmitriy/phpmem/my_dumpfile'.$i.'.json', 'w'));

But when I compare files with 2 and 43 iteration almost nothing changed.

I attached two files fith 2 and 43 iteration. https://drive.google.com/open?id=1amDpzmyIel0QWdYqZp64F-f5L5fisqvC

Any ideas, why I don't see anything?

BitOne commented 6 years ago

Hi @Shkarbatov ,

It's difficult to tell exactly what is happening. It could be one of the following reason:

Shkarbatov commented 6 years ago

you didn't reach yet 10.000 items in the GC buffer,

I try it with the GC: gc_collect_cycles(); meminfo_dump(fopen('/home/dmitriy/phpmem/my_dump_file_'.$i.'.json', 'w'));

Result is the same.

Shkarbatov commented 6 years ago

sometimes a memory leak in PHP can comes from one of its extension.

I understand this, but if I see difference in meminfo dump, isn't it's don't mean that I can see difference in meminfo?

For 2 iteration:

string - 30415 - 1271927
array - 16665 - 1199880
null - 6708 - 107328
boolean - 5667 - 90672
integer - 3025 - 48400

For 43 iteration:

string - 32970 - 1345086
array - 18103 - 1303416
null - 6720 - 107520
boolean - 5937 - 94992
integer - 3117 - 49872
Shkarbatov commented 6 years ago

If XHProf show me, there is no any difference in memory between 2 and 43 iteration, but memory_get_usage() show that memory is rising. What it can be? GC run in each iteration.

BitOne commented 6 years ago

Maybe you have a small leak of PHP items that you can see in phpMeminfo and a big leak coming from an extension. Can you provide the two full dump files instead of the summaries (for your iterations 2 and 43) ?

Shkarbatov commented 6 years ago

Adding dumps 3 and 389 iteration: https://drive.google.com/drive/folders/1izeyMBlf85y09Or0BeCd70yfqE8_ygWb?usp=sharing

Shkarbatov commented 6 years ago

In example there is Symfony\Component\Stopwatch\StopwatchPeriod, I disabled it and repeated script - result is the same.

shxofficial commented 6 years ago

Is there any update on this? i have the same situation but cannot solve it...

BitOne commented 6 years ago

Hey @Shkarbatov and @shxofficial ,

Do you have any code that you could share so we can reproduce the issue?

By the way, I'm thinking of adding an option to dump the content of the strings. Would that be helpful for you?