I am using JDBC along with UCanAccess in order to create a connection to a MS Access file via direct filepath to store a specific table into a JSON object. However, my line of code
conn = DriverManager.getConnection(s1+inFilePath, user, pass);
where conn is an uninitialized Connection object, that creates the connection is causing some sort of memory leak that eventually causes the GC overhead limit to be exceeded.
Is there any way to get around this problem? I have tried changing the heap size with no results.
It is not a memory leak. UCanAccess is consuming memory as part of its normal operation.
UCanAccess uses an HSQLDB "mirror" of the Access database to support SQL operations, and by default that mirror database is created in memory. Therefore if you connect to an Access database that has tables containing 30 MB of data then UCanAccess will use ~30 MB of memory to store the mirror database.
Appending ;memory=false
to the connection URL will tell UCanAccess to create the HSQLDB mirror database on disk instead of in memory. That will will reduce the memory requirements significantly but it will also take longer to establish the connection (i.e., create the mirror database).
UCanAccess also "mirrors" all of the tables that it finds in the specified database. So, if you are only interested in working with one particular table in a database named "main.accdb" then you can
Using the above procedure, UCanAccess only mirrors the one table.
There are several other options to control the mirroring behaviour of UCanAccess; see the UCanAccess website for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With