This question is derived from here .
I have three large lists containing python objects ( l1 , l2 and l3 ). These lists are created when the program starts, and they occupy a total of 16 GB of RAM. The program will be used exclusively for Linux.
I do not need to modify these lists or the objects in these lists in any way or form after they are created. They must remain in memory until the program exits.
I use os.fork () and the multiprocessing module in my program to create many subprocesses (up to 20 at present). Each of these subprocesses should be able to read three lists ( l1 , l2 and l3 ).
My program is working fine and pretty fast. However, I have problems with memory consumption. I was hoping that each subprocess could use three lists without copying them into memory due to the copy-on-write approach in Linux. However, this is not so, since a link to an object in any of these lists will lead to an increase in related links and, therefore, will lead to a copy of the entire memory page.
So my question is:
Is it possible to disable the counting of links to l1 , l2 and l3 and all objects in these lists? Basically, for the whole object (including metadata, such as ref count), it is read-only, so it will never be modified under any circumstances (this, I believe, will allow me to use copy-to-write).
Currently, I'm afraid that I need to switch to another programming language in order to complete this task due to a βfunctionβ (reference counting) that I do not need at the moment, but which is still being imposed on me and causes unnecessary problems.
python
Fableblaze
source share