Description
I'm pretty sure there's a memory leak in send-message, at least under some circumstances. I have narrowed it down to just running this loop:
(dotimes [n 2000]
(let [uuid1 (myutil/random-uuid)
uuid2 (myutil/random-uuid)
uuid3 (myutil/random-uuid)]
(println "sending TEST email subj " uuid1)
(try (let [fromname "my name blalablabla" ]
(postalemail/send-message mycred/conn-from-me
{
:from (str fromname " <" mycred/crm-email ">")
:to blabla@gmail.com
:subject uuid2
:body [ {:type "text/html" :content uuid3 }] })
true) ; success in sending e-mail
(catch Exception e (do (myutil/write-important-log
; failed sending e-mail
"TEST Send-Email exception: " (.getMessage e))
false ; failure in sending
)))
(Thread/sleep 10000)
))
When this loop is running, and a message is sent every 10sec, I can clearly see memory use rising (using top) from 8.3% to 9.1% over around 15 minutes. (sending around 50-100 e-mails).
If this code does not run, memory use doesn't rise.
If anyone has any idea on why that happens, and how to fix that, I'd be happy to hear.
I suppose some memory needs to be freed after sending the e-mail, but I don't really know the Java API and how to do that.
Thanks