[ Python ] 메모리 누수 해결에 도움되는 패키지 소개

2019. 6. 5. 16:38분석 Python/구현 및 자료

728x90

도움이 되셨다면, 광고 한번만 눌러주세요.  블로그 관리에 큰 힘이 됩니다 ^^

최근에 UI를 만들어야 하는 일을 하고 있었는데, 같은 것을 실행하는데 누적되는 문제가 발생하였다.

gc.collect()를 해도 소용이 없어서, 여러 가지를 찾다가 다음과 같은 것이 나와서 공유한다.

 

실제 테스트를 하니, 같은 작업을 반복할 때는 그만큼 데이터가 계속해서 쌓이지는 않았다.

 

아직 문제는 할당된 메모리가 다시 돌아오지 않는 다는 점....... (어디로 간 거냐....)

 

## 190605 기준 최신 버전은  5.2입니다.

# installing jemalloc
wget https://github.com/jemalloc/jemalloc/releases/download/5.2.0/jemalloc-5.2.0.tar.bz2
tar xvjf jemalloc-5.1.0.tar.bz2
cd jemalloc-5.1.0
./configure
make
sudo make install


LD_PRELOAD=/usr/local/lib/libjemalloc.so python ~~~~~~~~~.py

 

https://zapier.com/engineering/celery-python-jemalloc/

 

Decreasing RAM Usage by 40% Using jemalloc with Python & Celery

At Zapier, we're running hundreds of instances of Python and Celery, a distributed queue that helps us perform thousands of tasks per second. With that kind of load, the RAM usage has become a point of contention for us.To process all the activity within o

zapier.com

http://egloos.zum.com/mcchae/v/11175458

 

[Python] gc.collect() 후에도 메모리 남아있는 문제

우선 지난번에 guppy를 이용한 메모리 소비량 살펴보기를 올린 적 있습니다. 이것이 단순 소비 메모리만을 리눅스에서 살펴볼 때에는 guppy를 이용하는 것이 너무 프로그램을 지연시키는 문제가 말생하므로 /proc/[pid]/status 내용을 확인하여 VmRSS 내용을 확인하는 것이 더 빠르고 나을 수 있었습니다. 예를 들어, /proc$ ca

egloos.zum.com

 

728x90