https://kotlinlang.org logo
#exposed
Title
# exposed
o

oshai

05/30/2018, 6:22 AM
Hi @tapac - we upgraded from exposed 9.0.1 to 10.0.2 and I think there is a memory leak. for example with 9.0.1 we have one instance of
org.jetbrains.exposed.sql.vendors.MysqlDialect
and with 10.0.2 we had 277725 instances when I took a memory dump. So it is either a leak or we are not using exposed as we should with the new version. Do you have an idea what can go wrong?
t

tapac

05/30/2018, 8:30 AM
Hi, the only thing what comes to mind is that you call Database.connect() before every transaction. It's unnecessary, you should call connect only once per different database.
o

oshai

05/30/2018, 9:27 AM
ok, and can it be disconnected? In version 9.0.1 we didn't have that issue so we were just calling it on every transaction like you said
t

tapac

05/30/2018, 9:34 AM
Not so far time ago Dialects were an
objects
, i.e. singletons. But as Dialect can have it's own state (dialect metadata depends on concrete database version you connect), this part was reworked and now you achieve new Dialect instance for each
Database
. So you may work with two different MySQL databases concurrently
o

oshai

05/30/2018, 9:37 AM
awesome, we will work on it and see if it is ok
o

oshai

05/30/2018, 9:43 AM
we probably should write somewhere that now you should only connect once to a database (this was not the guidance before)
t

tapac

05/30/2018, 9:44 AM
We use something like :
Copy code
object Settings {
   val db by lazy { 
       Database.connect("")
   }
}
o

oshai

05/30/2018, 11:43 AM
we will wrap database with spring bean
I will add your example to docs
👍 1
added example to docs and did some more alterations to relevant pages: https://github.com/JetBrains/Exposed/wiki/DataBase-and-DataSource