Closed
Description
We have noticed a significant increase of memory consumption in 1.3.0 compared to 1.2.2, especially when reading large tables. That memory also isn't freed after closing and destroying the database connection.
For example, reading a 175MB table (data length reported by MySQL Workbench) results in ~600MB additional memory usage each time that table is read, i.e. reading it twice adds 1.2GB memory usage.
Reverting to RMariaDB version 1.2.2 stops the issue from showing up.
Our Database server runs on MySQL 8.0.34, if that's important.
I'm not quite sure how to provide a useful reprex, considering a database connection is involved. If there's something I can do that makes it more useful, please don't hesitate to ask for it!
conn2 <- DBI::dbConnect(
drv = RMariaDB::MariaDB(),
dbname = "<scrubbed>",
host = "<scrubbed>",
port = <scrubbed>,
client.flag = 0,
username = "<scrubbed>",
password = "<scrubbed>"
)
gc()
#> used (Mb) gc trigger (Mb) max used (Mb)
#> Ncells 982745 52.5 1911970 102.2 1437825 76.8
#> Vcells 1694914 13.0 8388608 64.0 2839637 21.7
tab <- DBI::dbReadTable(conn2, "<some_large_table_here>")
gc()
#> used (Mb) gc trigger (Mb) max used (Mb)
#> Ncells 986156 52.7 1911970 102.2 1437825 76.8
#> Vcells 80231910 612.2 105323487 803.6 87372344 666.6
tab <- DBI::dbReadTable(conn2, "<some_large_table_here>")
gc()
#> used (Mb) gc trigger (Mb) max used (Mb)
#> Ncells 986395 52.7 1911970 102.2 1437825 76.8
#> Vcells 155208358 1184.2 198340906 1513.3 162327962 1238.5
tab <- DBI::dbReadTable(conn2, "<some_large_table_here>")
gc()
#> used (Mb) gc trigger (Mb) max used (Mb)
#> Ncells 986634 52.7 1911970 102.2 1437825 76.8
#> Vcells 230184808 1756.2 296869810 2265.0 240858902 1837.7
With 1.2.2:
conn2 <- DBI::dbConnect(
drv = RMariaDB::MariaDB(),
dbname = "<scrubbed>",
host = "<scrubbed>",
port = <scrubbed>,
client.flag = 0,
username = "<scrubbed>",
password = "<scrubbed>"
)
gc()
#> used (Mb) gc trigger (Mb) max used (Mb)
#> Ncells 1019389 54.5 2016667 107.8 1437825 76.8
#> Vcells 1758110 13.5 8388608 64.0 3082381 23.6
tab <- DBI::dbReadTable(conn2, "<some_large_table_here>")
gc()
#> used (Mb) gc trigger (Mb) max used (Mb)
#> Ncells 1021670 54.6 2016667 107.8 1437825 76.8
#> Vcells 17757486 135.5 55061346 420.1 57938202 442.1
tab <- DBI::dbReadTable(conn2, "<some_large_table_here>")
gc()
#> used (Mb) gc trigger (Mb) max used (Mb)
#> Ncells 1021684 54.6 2016667 107.8 1437825 76.8
#> Vcells 17757517 135.5 69716149 531.9 73918443 564.0
tab <- DBI::dbReadTable(conn2, "<some_large_table_here>")
gc()
#> used (Mb) gc trigger (Mb) max used (Mb)
#> Ncells 1021698 54.6 2016667 107.8 1437825 76.8
#> Vcells 17757548 135.5 55772920 425.6 73918443 564.0