Python tips for memory optimization

前端 未结 7 1820
心在旅途
心在旅途 2020-12-24 04:07

I need to optimize the RAM usage of my application.
PLEASE spare me the lectures telling me I shouldn\'t care about memory when coding Python. I have a memory problem be

7条回答
  •  时光说笑
    2020-12-24 04:08

    For a web application you should use a database, the way you're doing it you are creating one copy of your dict for each apache process, which is extremely wasteful. If you have enough memory on the server the database table will be cached in memory (if you don't have enough for one copy of your table, put more RAM into the server). Just remember to put correct indices on your database table or you will get bad performance.

提交回复
热议问题