Opened 11 years ago
Closed 11 years ago
#13817 closed defect (fixed)
Memory leak in python vboxapi
| Reported by: | ali123 | Owned by: | |
|---|---|---|---|
| Component: | other | Version: | VirtualBox 4.3.20 |
| Keywords: | vboxapi python sdk | Cc: | |
| Guest type: | all | Host type: | Windows |
Description
This is an issue with the python library in the sdk: sdk/install/vboxapi/__init__.py
If you create, then delete, a WEBSERVICE VirtualBoxManager object then it leaves 2 uncollectable objects in the garbage collector: vboxapi.VirtualBoxManager and ZSI.parse.ParsedSoap. The first is due to a circular reference, and the second due to a typo.
To replicate:
import gc
from vboxapi import VirtualBoxManager
creds = {'url': 'http://SERVER:18083', 'user': 'USERNAME', 'password': 'PASSWORD'}
manager = VirtualBoxManager('WEBSERVICE', creds)
del manager
gc.collect()
gc.garbage
This displays the uncollectable objects:
[<vboxapi.VirtualBoxManager object at 0x0235DED0>, <ZSI.parse.ParsedSoap instance at 0x0413D7D8>]
To workaround: Perform the following instead of "del manager":
manager.platform.disconnect() del manager.mgr del manager
The circular reference issue:
__init__.py has a circular reference at the end of the __init__ method of the VirtualBoxManager class (line 996):
self.mgr = self;
The VirtualBoxManager class also defines a __del__ method (line 998).
A circular reference and a __del__ method mean that the object cannot be collected by the garbage collector (see https://docs.python.org/2/library/gc.html#gc.garbage).
The typo:
In file __init__.py, class PlatformWEBSERVICE, method deinit it calls disconnect(), where it should call self.disconnect() (line 878).
Change History (5)
comment:1 by Klaus Espenlaub, 11 years ago
Thanks for letting us know... the circular reference was trivially replaced by a property and the rest you already served on the silver platter. Will try to wrap this up ASAP and pass you a new SDK package for testing.
comment:2 by Klaus Espenlaub, 11 years ago
Hopefully fixed SDK package is at https://www.virtualbox.org/download/testcase/VirtualBoxSDK-4.3.21-98155.zip - feedback is very welcome.
comment:3 by ali123, 11 years ago
I've tested the new one and the problem is fixed. Thanks very much.
comment:4 by Klaus Espenlaub, 11 years ago
Thanks for the quick feedback... will be included in the next 4.3 release.
comment:5 by Frank Mehnert, 11 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Fix is part of VBox 4.3.22.