Kohana Doctrine Error – Exhausted

Today, I am developing a sub-module of a web-application and have experienced a max-memory usage limit error or “Allowed memory size fatal error”.

out of memory problem

I know that the doctrine module uses memory based on how you define and build your database. It combines dependencies and loads all necessary objects so that it will be ready for use. Now the problem is, while you develop your application – the system will fail as you are still putting the pieces in place.

Kohana, on the other hand displays a complete debug-trace of the page if ever it fails to load. This is for most cases as long as the failure is not of type “fatal error”. Now, the problem arises when kohana attempts to display the entire trace with doctrine objects loaded. At some cases, the page would load with a memory exhausted problem and at some cases also, it displays a white screen! White screens are horrifying because there’s no error or whatsoever displayed on top of not completing the desired action for that particular function / page.

I have come up with a temporary solution that would help reduce greatly the data loaded-then-displayed by kohana – that is, setting the hydration mode temporarily to “array” instead of “object”.

the fix

By applying this solution, we can work with smaller amounts of data for the mean time as we develop. This will display a kohana error page with less and more relevant data to work with.

I’m also thinking of a way to extend kohana’s error reporting to display a better error page to work with in the future but I am not gifted with that experiment time at the moment.