| 1 | # Open an atomic model and close it 100 times and a lot of memory is leaked.
|
|---|
| 2 | # This makes it hard to run nogui scripts on entire Protein Databank.
|
|---|
| 3 | #
|
|---|
| 4 | # Test memory use: chimerax --nogui --silent
|
|---|
| 5 | # Then command "open test_memleak.py"
|
|---|
| 6 | #
|
|---|
| 7 | # Starting chimerax in nogui on macOS 12.4 gives 68 Mbytes memory use reported by Mac Activity Monitor.
|
|---|
| 8 | # For small structure 17gs (0.38 MB cif file) memory use goes to 145 Mbytes.
|
|---|
| 9 | # For larger structure 7azs (42 MB cif file) memory use goes to 526 Mbytes.
|
|---|
| 10 | # For a PDB format file 1s72 (9 MB pdb file) memory use goes to 1450 Mbytes.
|
|---|
| 11 | # For EMDB map 1080 (4 MB ccp4 file) memory use goes to 71 Mbyte.
|
|---|
| 12 | # For 7azs opening without adding to open models memory use goes to 280 Mbytes.
|
|---|
| 13 | #
|
|---|
| 14 | n = 100
|
|---|
| 15 | from time import time
|
|---|
| 16 | from chimerax.core.commands import run
|
|---|
| 17 | from chimerax.mmcif import open_mmcif
|
|---|
| 18 | #import gc
|
|---|
| 19 | path = '/Users/goddard/Downloads/ChimeraX/PDB/7azs.cif'
|
|---|
| 20 | for i in range(n):
|
|---|
| 21 | t0 = time()
|
|---|
| 22 | # models = run(session, 'open 17gs')
|
|---|
| 23 | models = run(session, 'open 7azs')
|
|---|
| 24 | # models = run(session, 'open 1s72 format pdb')
|
|---|
| 25 | # models = run(session, 'open 1080 from emdb')
|
|---|
| 26 | session.models.close(models)
|
|---|
| 27 | # models = open_mmcif(session, path)[0]
|
|---|
| 28 | # for s in models:
|
|---|
| 29 | # s.delete()
|
|---|
| 30 | t1 = time()
|
|---|
| 31 | if i % 10 == 0:
|
|---|
| 32 | print ('%d %.2f' % (i, t1-t0))
|
|---|
| 33 | # print ('%d %.2f %d' % (i, t1-t0, len(gc.garbage)))
|
|---|
| 34 |
|
|---|