To test the assumption that gmxapi.commandline_operation has memory leaks, I performed the following two tests:
- Test A: Use
os.system to run the GROMACS grompp for 20000 times to generate 20000 tpr files. (See Test_A.py below.)
- Test B: Use
gmxapi.commandline_operation to run GROMACS grompp commands to generate 20000 tp files. (See Test_B.py below.)
Each of the 20000 iterations in each test was timed. Both the executions of Test_A.py and Test_B.py were memory-profiled by the mprof run command (e.g. mprof run python Test_A.py) enabled by memory-profiler, which measured the memory usage every 0.1 seconds. Below I plotted the wall time per tpr generation against the number of grompp commands executed (left) the memory usage as a function of time (right).

It can be seen from the figure above that memory usage increased as a function of time when gmxapi.commandline_operation was used. On the other hand, in Test A, where os.system was used, the memory usage remained roughly constant, which to my understanding is because that os.system ran the GROMACS grompp command as a separate process and the allocated memory was released once each grompp command was finished. That is, gmxapi.commandline_operation seems to have memory leaks.
I'll paste Test_A.py and Test_B.py in the next comment.
To test the assumption that
gmxapi.commandline_operationhas memory leaks, I performed the following two tests:os.systemto run the GROMACS grompp for 20000 times to generate 20000 tpr files. (SeeTest_A.pybelow.)gmxapi.commandline_operationto run GROMACS grompp commands to generate 20000 tp files. (SeeTest_B.pybelow.)Each of the 20000 iterations in each test was timed. Both the executions of
Test_A.pyandTest_B.pywere memory-profiled by themprof runcommand (e.g.mprof run python Test_A.py) enabled by memory-profiler, which measured the memory usage every 0.1 seconds. Below I plotted the wall time per tpr generation against the number of grompp commands executed (left) the memory usage as a function of time (right).It can be seen from the figure above that memory usage increased as a function of time when
gmxapi.commandline_operationwas used. On the other hand, in Test A, whereos.systemwas used, the memory usage remained roughly constant, which to my understanding is because thatos.systemran the GROMACS grompp command as a separate process and the allocated memory was released once each grompp command was finished. That is,gmxapi.commandline_operationseems to have memory leaks.I'll paste
Test_A.pyandTest_B.pyin the next comment.