Bug #64394 Memory doesn't free after cursor close
Description:
Memory doesn't get freed or objects are not cleaned up by the automatic garbage collector at runtime.
How to repeat:
# The following is part of the unittests for creating the fix
class BugGarbage(tests.MySQLConnectorTests):
def setUp(self):
self.sample_size = 4
self._reset_samples()
gc.collect()
def _reset_samples(self):
self.samples = [0,] * self.sample_size
def _assert_flat_line(self, samples):
for i in range(0, len(samples)-1):
try:
if samples[i] != samples[i+1]:
self.fail("No flat-line for number of collected objects")
except IndexError:
pass # We are at the end.
def test_cursor(self):
config = self.getMySQLConfig()
cnx = connection.MySQLConnection(**config)
# Create a cursor and close using close()-method
for i in range(0, self.sample_size):
cursor = cnx.cursor()
cursor.close()
self.samples[i] = len(gc.get_objects())
self._assert_flat_line(self.samples)
self._reset_samples()
# Create a cursor and rely on destructor to close
for i in range(0, self.sample_size):
cursor = cnx.cursor()
self.samples[i] = len(gc.get_objects())
self._assert_flat_line(self.samples)
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.048 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: Memory doesn't get freed or objects are not cleaned up by the automatic garbage collector at runtime. How to repeat: # The following is part of the unittests for creating the fix class BugGarbage(tests.MySQLConnectorTests): def setUp(self): self.sample_size = 4 self._reset_samples() gc.collect() def _reset_samples(self): self.samples = [0,] * self.sample_size def _assert_flat_line(self, samples): for i in range(0, len(samples)-1): try: if samples[i] != samples[i+1]: self.fail("No flat-line for number of collected objects") except IndexError: pass # We are at the end. def test_cursor(self): config = self.getMySQLConfig() cnx = connection.MySQLConnection(**config) # Create a cursor and close using close()-method for i in range(0, self.sample_size): cursor = cnx.cursor() cursor.close() self.samples[i] = len(gc.get_objects()) self._assert_flat_line(self.samples) self._reset_samples() # Create a cursor and rely on destructor to close for i in range(0, self.sample_size): cursor = cnx.cursor() self.samples[i] = len(gc.get_objects()) self._assert_flat_line(self.samples)