[CONPY-99] Memory not deallocated from already read resultset Created: 2020-08-10  Updated: 2020-08-20  Resolved: 2020-08-16

Status: Closed
Project: MariaDB Connector/Python
Component/s: Generic
Affects Version/s: 1.0.0
Fix Version/s: 1.0.1

Type: Bug Priority: Critical
Reporter: Luciano Barcaro Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: None


 Description   

Hi, I wrote a little program to do some maintenance here on a big table(330M rows) and I noted that the connector is not releasing memory from datasets consumed.

As I can't load all the data into memory, I'm reading it in chunks, as shown below:

import mariadb
import resource
 
db = mariadb.connect(...)
qr = db.cursor()  # doesn't matter if it's buffered or not..
 
sz = 400
last_id = 0
 
while True:
    qr.execute('select a, b, c from big_table where id > ? limit ?', (last_id, sz))
 
    usage = resource.getrusage(resource.RUSAGE_SELF)
    print(f'Mem: {usage[2]}')  # here I'm monitoring how much memory is allocated - It's always a growing number
 
    rows = qr.fetchall()  # Consume dataset
 
    last_id += sz
 
    if len(rows) < sz:
        break

With mysql.connector the memory allocated is almost constant.



 Comments   
Comment by Georg Richter [ 2020-08-16 ]

fixed rev. 74933240baf17f5dd21a53c0baaf16d3ee5ee087

Generated at Thu Feb 08 03:30:15 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.