I have low memory VPS container based (LXC), therefore I can't change kernel parameter such as swap memory swappiness. Even though there is swap allocated from built-in VPS when I check with htop, I don't know why OOM killer still killing myprogram.py and seems didn't utilize the swap when memory is 100% used.
Therefore I want to run myprogram.py with utilizing disk as main memory without modifying main script, I have my code like this:
def main():
import numpy as np
terrible_memory_alloc = np.zeros(99999999)
if __name__=='__main__':
main()
I expect there is wrapper like this that will allocate memory to disk when memory is being full:
def main():
import numpy as np
terrible_memory_alloc = np.zeros(99999999)
if __name__=='__main__':
with open('myvirtualram.file', 'wb') as file:
run_inside_disk(main, file)