#1
  1. A Change of Season
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    3,558
    Rep Power
    221

    Fatal error: Allowed memory size of 67108864 bytes exhausted


    Hi;

    The queries are all simple and I am using relatively simple queries.

    The server is very strong as well.

    How can I deal with this properly?

    Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 82 bytes) in /home/webmoo/public_html/system/database/drivers/mysqli/mysqli_result.php on line 214
    Thanks

    ================================================================
    Profiler:

    MEMORY USAGE
    2,014,552 bytes

    BENCHMARKS
    Loading Time: Base Classes 0.0079
    Controller Execution Time ( Launch Prospects / Index ) 0.1510
    Total Execution Time 0.1591

    DATABASE: machine (Launch_prospects:$db) QUERIES: 15 (0.0538 seconds)



    Server people say
    its saying there is a memory limit error that means the site software is trying to use that much. For example, in the error it states the memory amount 67108864 was exhausted, which means it ran into the 64M limit, and needed more ram to finish.
    Me
    So the apps profiler is bs?
    Them
    Probably
    Me
    wtf
    Awkward silence...
    Last edited by English Breakfast Tea; June 7th, 2018 at 10:22 PM.
  2. #2
  3. Impoverished Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,885
    Rep Power
    9646
    64MB isn't much. But before raising that you have to figure out where the memory is going, and without seeing all your code that's kinda sorta totally impossible to do.

    No idea where to start looking? Familiar with XDebug much? Set it up, get profiling enabled, have it profile the request to a dump file, then view the dump file with something that understands cachegrind files.
  4. #3
  5. A Change of Season
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    3,558
    Rep Power
    221
    What about what profiler says? Is it really bs?

    DATABASE: machine (Launch_prospects:$db) QUERIES: 15 (0.0542 seconds)
    MEMORY USAGE 2,013,976 bytes
    That's like 2mb.

    Is that what you mean? https://chrome.google.com/webstore/d...kmoaaaoc?hl=en
    Last edited by English Breakfast Tea; June 7th, 2018 at 11:00 PM.
  6. #4
  7. A Change of Season
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    3,558
    Rep Power
    221
    Also what Chrome Inspector says, is more aligned with Codeigniter profiler ===> Chrome <===

    The php part is taking much less time than front-end scripts.



    Sorry, this is not very clean code.

    I understand it can be improved, but is it the reason based on the info?
    Last edited by English Breakfast Tea; June 8th, 2018 at 05:08 AM.
  8. #5
  9. Impoverished Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,885
    Rep Power
    9646
    The profiler may be telling you that 2MB was in use. That doesn't tell you why mysqli_result.php needed another 62+MB.

    Educated guess is that whatever query it was executing returned too many results. Way too many.
  10. #6
  11. A Change of Season
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    3,558
    Rep Power
    221
    You are right because this is the only page with a query that returns many rows.

    However, I don't think I am doing wrong with the SQL (unless the SQL is bad?)

    Just getting the total number of records for pagination:

    Explain
    Code:
    EXPLAIN 
    SELECT COUNT(*) AS c
         FROM launch_launch_prospect
              INNER JOIN launch_launches ON launch_launches.id = launch_launch_prospect.launch_id
                    AND launch_launches.user_id = 1
         WHERE launch_launch_prospect.launch_id = 112
    Also the database online is way way way biger than 5000 records.

    Advise?
    Last edited by English Breakfast Tea; June 8th, 2018 at 02:44 AM.
  12. #7
  13. Impoverished Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,885
    Rep Power
    9646
    Paginate the results? Process them in a batch, like 1000 or 5000 or so at a time.
  14. #8
  15. A Change of Season
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    3,558
    Rep Power
    221
    Hi;

    Misunderstood I guess.

    That query gets the total number of records.

    Not sure why you say process them in batch. It just gives a total number, so I use and build pagination.

    Then I get the results 100 per page.
  16. #9
  17. Impoverished Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,885
    Rep Power
    9646
    Found mysqli_result.php. Line 214 is a fetch_assoc() so that wouldn't be the reason PHP runs out of memory. It'd be somewhere else.

    Which of those calls in your code is the one that ends up running out of memory?
  18. #10
  19. A Change of Season
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    3,558
    Rep Power
    221
    Hello;

    What's the point of application profiler if it says the query is taking 0.003 seconds BUT it's still shet.

    I don't want to know it took 0.003 seconds because that's not solving my problem.

    I need to know why it's running out of memory. Profiler is telling me 2mb while PHP on the screen says it's using 67 mb. So yes somewhere else the app is chewing it. Like you said fetch_assoc. Which is database related.

    Do know what I am saying?

    Phuck this profiler.

    I might as well play angry birds instead of profiling.
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2016
    Posts
    142
    Rep Power
    66
    If you increase the php memory limit by several Megabytes and your code still consumes all the available memory, you likely have a logic error that will consume all available memory, regardless of how much you make available.

    If so, you will need to find and fix what the code is doing. Typically, these type of things would be due to a 'forever' loop that never reaches an exit condition or by not creating/initializing an array variable that gets reused and gets 'appended' to, rather than starting empty each time it gets used.
  22. #12
  23. A Change of Season
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    3,558
    Rep Power
    221
    No. Can't be forever looped for sure. Page loads fast. Those errors show nothing.

    Also not creating/initializing an array creates "unknown variable notices".

    I was betting on profiler but it's no use. I need to figure out something else. Maybe learn Xdebug. Maybe also useless in this case. not sure.

    All I know right now is that the site slows down when there are a more than 2000k page loads per minute.
    Last edited by English Breakfast Tea; June 9th, 2018 at 12:08 AM.
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2016
    Posts
    142
    Rep Power
    66
    No. Can't be forever looped for sure. Page loads fast. Those errors show nothing.
    Until all the memory is consumed, producing the fatal runtime error you are getting and halting execution.

    Also not creating/initializing an array creates "unknown variable notices".
    This is an incorrect conclusion as well. Assigning a value to an array creates the array if it doesn't already exist, which doesn't produce a php error, but would continue to add elements to an array that already exists.

IMN logo majestic logo threadwatch logo seochat tools logo