VirtualBox

Ticket #13817 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Memory leak in python vboxapi

Reported by: ali123 Owned by:
Priority: major 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

comment:1 Changed 2 years ago by klaus

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 Changed 2 years ago by klaus

Hopefully fixed SDK package is at https://www.virtualbox.org/download/testcase/VirtualBoxSDK-4.3.21-98155.zip - feedback is very welcome.

comment:3 Changed 2 years ago by ali123

I've tested the new one and the problem is fixed. Thanks very much.

comment:4 Changed 2 years ago by klaus

Thanks for the quick feedback... will be included in the next 4.3 release.

comment:5 Changed 2 years ago by frank

  • Status changed from new to closed
  • Resolution set to fixed

Fix is part of VBox 4.3.22.

Note: See TracTickets for help on using tickets.

www.oracle.com
ContactPrivacy policyTerms of Use