lift / lift/framework

RequestVar cleanup not being called when request ends

Open
#1,160 1 comment 0 reactions 1 assignee View on GitHub

@Shadowfiend is already working on this.

Since May 13, 2014.

P:Normal T:Defect
Dominant language
Scala
Stars
1.3k
Forks
275
PR merge metrics
No merged PRs in 30d

Description

Hi David,

Am reporting bug [[url:https://groups.google.com/forum/#!searchin/liftweb/noel/liftweb/1_7JAJwAfto/Ktjn_W_kDtAJ|as requested]].

My problem is that RequestVar cleanupFunc doesn't run at the end of each http request, which is resulting in a memory leak for my usage:

I'm using a RequestVar to provide a service which needs to be disposed of correctly when it is no longer needed, ie it is not advised to leave it to the garbage collector to tidy up. Therefore I registered the RequestVar to clean up after use via the registerCleanupFunc .
However, the behaviour I'm seeing is that for the first use only (1st http request) the service is shutdown correctly. Any usages after this don't seem to be clean up properly, ie the lambda I passed to registerCleanupFunc isnt being called again.

Here is my code:

object HttpDispatchConnection extends RequestVar[Http](new Http%28%29) {
registerCleanupFunc(ignore => is.shutdown())
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.