python代码内存溢出报错

环境是

4核+8G的7.3CentOS系统(强调,系统是64位的)

 

[2018-07-03 15:37:58,098][MainThread:140513684158528][task_id:web.signals.notice_signal][notice_signal.py:1011][ERROR]['>=' not supported between instances of 'str' and 'int']
[2018-07-03 15:54:26,825][b'uWSGIWorker5Core0':140397910317120][task_id:django.request][exception.py:135][ERROR][Internal Server Error: /api/v1/XXX/]
Traceback (most recent call last):
  File "/usr/local/python3.6.2/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/usr/local/python3.6.2/lib/python3.6/site-packages/django/core/handlers/base.py", line 217, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/python3.6.2/lib/python3.6/site-packages/django/core/handlers/base.py", line 215, in _get_response
    response = response.render()
  File "/usr/local/python3.6.2/lib/python3.6/site-packages/django/template/response.py", line 107, in render
    self.content = self.rendered_content
  File "/usr/local/python3.6.2/lib/python3.6/site-packages/rest_framework/response.py", line 72, in rendered_content
    ret = renderer.render(self.data, accepted_media_type, context)
  File "/usr/local/python3.6.2/lib/python3.6/site-packages/rest_framework/renderers.py", line 105, in render
    separators=separators
  File "/usr/local/python3.6.2/lib/python3.6/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/local/python3.6.2/lib/python3.6/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/local/python3.6.2/lib/python3.6/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
MemoryError

 

这种内存溢出错误。一旦报错就是一堆堆的报错,完全找不到头绪,

找了好久发现这种错误主要是两点原因。

1.Python解释器是32位的(或者只支持32位),当内存使用率到了2GB以上之后,就会内存溢出,好比   java设置了2G

2.代码级别的循环调用,百度一下有很多这个原因的。

 

解决方案重新编译安装python解释器

 

./configure --prefix=/usr/local/python3.6.2 --with-ssl --with-universal-archs=all

make

make install

  

其中 --with-universal-archs=all  

select architectures for universal build ("32-bit","64-bit", "3-way", "intel", "intel-32", or "all")

选择 architectures进行构建,然后我选择了all进行构建。其中 intel是英特尔芯片的意思。

转载于:https://www.cnblogs.com/can-H/articles/9259572.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值