Welcome Guest, Not a member yet? Register   Sign In
Memory Exception with Debugbar and Doctrine
#1
Bug 

Hi!

I was working on a project using CI 4 (in "development" environment) and Doctrine. All was working fine (creating new Entities, adding data to DB via Doctrine, retrieving them ...), but then I asked Doctrine (more specifically the EntityManager) to retrieve all the entries stored in DB for a specific Entity (3 entries in total). Suddenly, my page was loading indefinitely and eventually returned me an ErrorExceptionAllowed memory size of x bytes exhausted (tried to allocate x bytes)

The line concerned by this error was the 208th one of the System\Debug\Toolbar.php file:

PHP Code:
    $data['config'] = \CodeIgniter\Debug\Toolbar\Collectors\Config::display();

        if (
$response->CSP !== null)
        {
            
$response->CSP->addImageSrc('data:');
        }

        return 
json_encode($data);
    } 

It appears that the $data object was too big for the json_encode() method and led to an ErrorException. Indeed, I've found a debugbar.json file in the writable folder of 250+Mb.

This resulted in an Exception chain where the framework was trying to write and then read a file too big for the allowed memory size of the server. Sure enough, changing CI_ENVIRONMENT value to "production" resolved the issue (but that also meant no more Debugbar).

So, I was wondering if anyone had ever encountered such issue while working with CI 4 and Doctrine and, if so, how did you managed to resolve it?

Thanks!  Smile

(I can provide more information if needed: Doctrine implementation, CI 4 configuration, ...)
Reply
#2

I’m having a similar issue working with Google’s Firestore client. I believe my issue is that when an exception occurs the debug output tries to track down all loaded classes, which with a huge library like Firestore (and maybe Doctrine?) kicks it. I haven’t bothered troubleshooting it because in my case the underlying issue is some other exception triggering the trace, not a Norma toolbar load, but you might check you log files just in case. If it is loading fine on production it probably is just a case of loading too much data and there’s not much to be done for it.
Reply
#3

(12-18-2019, 01:35 AM)troturier Wrote: Hi!

I was working on a project using CI 4 (in "development" environment) and Doctrine. All was working fine (creating new Entities, adding data to DB via Doctrine, retrieving them ...), but then I asked Doctrine (more specifically the EntityManager) to retrieve all the entries stored in DB for a specific Entity (3 entries in total). Suddenly, my page was loading indefinitely and eventually returned me an ErrorExceptionAllowed memory size of x bytes exhausted (tried to allocate x bytes)

Hi, I have exactly the same issue with CI4+Doctrine+the Debug toolbar enabled. 


Allowed memory size of XXX bytes exhausted
SYSTEMPATH\Debug\Toolbar.php at line 162 

PHP Code:
return json_encode($data); 



Crashing from time to time (every 5 or 10 refresh).
Does anyone have a solution?

Thank you.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB