[ZBX-6910] Fatal error: Allowed memory size Created: 2013 Aug 20  Updated: 2019 Dec 10

Status: Open
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 2.1.3
Fix Version/s: None

Type: Incident report Priority: Trivial
Reporter: Ivo Kurzemnieks Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: frontend, memory, sql
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Zip Archive alerts.zip    
Issue Links:
Duplicate
is duplicated by ZBX-8924 Slow query on Administration->Notific... Closed

 Description   

This promblem has been before and appears again from time to time due to large amounts of data. The installation states that required memory is 128MB, but sometimes it's not enough. In Administration > Notifications I get error:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 42 bytes) in C:\Development\zabbix\frontends\php\include\db.inc.php on line 672 (line number may differ every time).
Currently the problem is with request to alerts table (report4.php: 190). My alerts table is about 45MB.
I added alerts table SQL dump just in case.



 Comments   
Comment by Alexei Vladishev [ 2013 Aug 20 ]

I am not sure it should be treated a s a bug. Obviously amount of required memory depends on size of our monitored environment.

Comment by Ivo Kurzemnieks [ 2013 Aug 21 ]

Wasn't sure either, but maybe this issue can server as discussion and raise awareness that these kind of problems still exist. My environment is rather small. We can treat it a bug, and say that this happens due to bad coding. For example the in file I mentioned, there is foreach cycle and in it there is a request to DB. That happens every time. In the end there is so much data, that PHP memory overflows. So here are some options:

1) Move request out of foreach, make request only once and try to assemble data afterwards.
2) Tell users to increase memory size, but as I've read sometimes even 512MB is not enough.
3) Before request, read the table metadata and if table size >= X, trow user friendly error to increase memory to Y.
4) Maybe the data can be loaded dynamically in small portions. For example load data via ajax as user scrolls down. Similary to popular pages like facebook or google reader, where content is loaded as user scrolls down.

I'm just shooting some random ideas.

Comment by Pavels Jelisejevs (Inactive) [ 2013 Sep 24 ]

We should check if we can optimize the code on the page to use less memory.

Comment by Ivo Kurzemnieks [ 2013 Sep 26 ]

The problem is with DB request it self. After executing query mysqli_query(), the amount of data is already about 65MB. While doing the while loop _fetch_assoc() the memory exeeds the limit in about 40k row. Tried experimenting with request with mysqli_real_request(), but with no luck so far. Maybe the query can be split into multiple smaller requests.
Issue temporary postponed.

Comment by richlv [ 2013 Sep 29 ]

not related to notifications page, but importing 98 hosts without any items or triggers needs more than 64mb of memory. maybe long term we should investigate some general approaches to reducing memory usage

Generated at Fri Mar 29 14:11:19 EET 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.