内存不足(已分配50855936)(试图分配50331646字节) [英] Out of memory (allocated 50855936) (tried to allocate 50331646 bytes)

查看:96
本文介绍了内存不足(已分配50855936)(试图分配50331646字节)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个查询:

$start = 0;
$number_of_posts = 10;

 $sql = $db -> prepare("
            SELECT  U.username, U.offer_photo, F.activities, A.id_offer, A.offer, A.role, A.content, A.date_post, A.limit, B.type_offer, C.local  
            FROM  type_offer B, local C, offer A
            INNER JOIN users U
            ON U.id_user = A.company_users_id_user1
            INNER JOIN company F
            ON F.users_id_user = A.company_users_id_user1   
            WHERE state = 0 
            AND
            A.type_offer_id_type_offer = B.id_type_offer 
            AND
            A.local_id_local = C.id_local
            ORDER BY date_post 
            DESC LIMIT ?, ?
            ");
        $sql -> bind_param('ii',$start, $number_of_posts);
        $sql -> execute();
        $sql -> bind_result($username, $offer_photo, $actividades, $id_oferta, $oferta, $cargo, $conteudo, $data_post, $data_limite, $tipo_oferta, $local); //problem here
            $sql->fetch();
            $sql-close;

我在phpinfo()中有memory_limit: 256M;但是我仍然遇到内存问题. 我已经尝试了此代码,但未成功:

And i have memory_limit: 256M in phpinfo(); However i still getting a problem with the memory. I already tried this code without success :

set_time_limit(0);
ini_set('memory_limit', '2000M');

所以我的问题是,可以优化查询,或者如何增加内存?我没有访问php.ini的权限,但我认为256MB应该足够,所以问题可能出在查询上.

So my question is, the query can be optimized, or how can i increase the memory ? I don't have access to php.ini, but i think 256MB should be enough, so maybe the problem is the query.

推荐答案

u.offer_photo是blob字段吗?如果是这样,我建议您重写逻辑,这样您就不会在实际显示它们之前获取blob数据.

Is the u.offer_photo a blob field? If so I'd suggest rewriting the logic so you don't fetch the blob data until you actually display it.

即使您可以通过增加分配来解决内存限制,使用过多的内存和脆弱的做法都是反社会的,因为将来数据库大小的增加很可能会破坏系统.

Even if you can get around the memory limit by increasing the allocation it's both anti-social to use excessive memory and brittle in that an increase in your database size in the future will likely break the system.

这篇关于内存不足(已分配50855936)(试图分配50331646字节)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆