Freddy
Freddy

Reputation: 693

Memory leak with addionatl NHibernate listeners?

i'm using Configuration.AppendListeners for some addional listeners. With the appened listeners the destructor is only called when the program ends - without the additional listeners the destructor is called on System.GC.Collect.

Ad a workaround I implemented IDisposable where I call following method:

    private void CleanUpConfigurationListener()
    {
        if (configuration == null) return;
        foreach (NHibernate.Event.ListenerType item in Enum.GetValues(typeof(NHibernate.Event.ListenerType)))
        {
            configuration.SetListener(item, null);  
        }
    }

With it, the destructor is called again.

Is it a memory leak?

I'm using NH 3.0 because of Fluent NHibernate (1.2).

Thanks for your answers.

Upvotes: 0

Views: 276

Answers (1)

Freddy
Freddy

Reputation: 693

It was my fault. I found the problem:

The code created a new SessionFactory for each new DAL-Session object :(

Upvotes: 1

Related Questions