 5f5c48e17b
			
		
	
	5f5c48e17b
	
	
	
		
			
			* Core: fix some memory leak sources * Core: run gc before detecting memory leaks * Core: restore caching in BaseClasses.MultiWorld * SM: move spheres cache to MultiWorld._sm_spheres to avoid memory leak * Test: add tests for world memory leaks * Test: limit WorldTestBase leak-check to py>=3.11 --------- Co-authored-by: Fabian Dill <fabian.dill@web.de>
		
			
				
	
	
		
			17 lines
		
	
	
		
			618 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			17 lines
		
	
	
		
			618 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| import unittest
 | |
| 
 | |
| from worlds.AutoWorld import AutoWorldRegister
 | |
| from . import setup_solo_multiworld
 | |
| 
 | |
| 
 | |
| class TestWorldMemory(unittest.TestCase):
 | |
|     def test_leak(self):
 | |
|         """Tests that worlds don't leak references to MultiWorld or themselves with default options."""
 | |
|         import gc
 | |
|         import weakref
 | |
|         for game_name, world_type in AutoWorldRegister.world_types.items():
 | |
|             with self.subTest("Game", game_name=game_name):
 | |
|                 weak = weakref.ref(setup_solo_multiworld(world_type))
 | |
|                 gc.collect()
 | |
|                 self.assertFalse(weak(), "World leaked a reference")
 |