Skip to content

Commit

Permalink
Replaced WeakDictionary with a regular dictionary.
Browse files Browse the repository at this point in the history
If you insert/update/delete under FlushMode.Commit or Never and don't flush the session, you'll get mem leaks.
  • Loading branch information
mausch committed Nov 14, 2011
1 parent 44def39 commit 2ba800a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 95 deletions.
2 changes: 1 addition & 1 deletion NHibernate.SolrNet.Tests/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void DoesntLeakMem() {
}
var listener = cfg.EventListeners.PostInsertEventListeners[0];
var addField = typeof (SolrNetListener<Entity>).GetField("entitiesToAdd", BindingFlags.NonPublic | BindingFlags.Instance);
var addDict = (WeakDictionary<ITransaction, List<Entity>>)addField.GetValue(listener);
var addDict = (IDictionary<ITransaction, List<Entity>>)addField.GetValue(listener);
Assert.AreEqual(0, addDict.Count);
}

Expand Down
6 changes: 4 additions & 2 deletions NHibernate.SolrNet.Tests/IntegrationTests2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

namespace NHibernate.SolrNet.Tests {
/// <summary>
/// This test does not reflect a valid usage of Solr, SolrNet or the SolrNet-NHibernate integration.
/// This test does not reflect a reference usage of Solr, SolrNet or the SolrNet-NHibernate integration.
/// Storing more than one type in a single Solr index should almost never be done.
/// Instead, the object model should be flattened.
/// Do not use as reference.
/// </summary>
[TestFixture]
Expand Down Expand Up @@ -112,7 +114,7 @@ private static IMappingManager Mappings(IMappingManager mapper) {

[FixtureSetUp]
public void FixtureSetup() {
//BasicConfigurator.Configure();
BasicConfigurator.Configure();
SetupSolr();

cfg = SetupNHibernate();
Expand Down
4 changes: 2 additions & 2 deletions NHibernate.SolrNet/Impl/SolrNetListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ namespace NHibernate.SolrNet.Impl {
/// <typeparam name="T"></typeparam>
public class SolrNetListener<T> : IListenerSettings, IAutoFlushEventListener, IFlushEventListener, IPostInsertEventListener, IPostDeleteEventListener, IPostUpdateEventListener where T : class {
private readonly ISolrOperations<T> solr;
private readonly IDictionary<ITransaction, List<T>> entitiesToAdd = new WeakDictionary<ITransaction, List<T>>();
private readonly IDictionary<ITransaction, List<T>> entitiesToDelete = new WeakDictionary<ITransaction, List<T>>();
private readonly IDictionary<ITransaction, List<T>> entitiesToAdd = new Dictionary<ITransaction, List<T>>();
private readonly IDictionary<ITransaction, List<T>> entitiesToDelete = new Dictionary<ITransaction, List<T>>();

/// <summary>
/// Automatically commit Solr after each update
Expand Down
89 changes: 0 additions & 89 deletions NHibernate.SolrNet/Impl/WeakDictionary.cs

This file was deleted.

1 change: 0 additions & 1 deletion NHibernate.SolrNet/NHibernate.SolrNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
<Compile Include="Impl\DelegatingSession.cs" />
<Compile Include="Impl\IListenerSettings.cs" />
<Compile Include="Impl\NHHelper.cs" />
<Compile Include="Impl\WeakDictionary.cs" />
<Compile Include="INHSolrQuery.cs" />
<Compile Include="ISolrSession.cs" />
<Compile Include="Impl\NHSolrQueryImpl.cs" />
Expand Down

0 comments on commit 2ba800a

Please sign in to comment.