BUG: Lucene.Net.Core.Util.RamUsageEstimator: Added .NET-specific calculation 
for determining the size of strings based on 
http://stackoverflow.com/a/8171099, which fixes the 
TestRamUsageEstimator.TestSanity() test.


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/2745153c
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/2745153c
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/2745153c

Branch: refs/heads/api-work
Commit: 2745153c9724e4c7b5bca2f492fb6610504b30da
Parents: aacb913
Author: Shad Storhaug <[email protected]>
Authored: Fri Mar 10 21:54:33 2017 +0700
Committer: Shad Storhaug <[email protected]>
Committed: Fri Mar 10 21:54:33 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Util/RamUsageEstimator.cs | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2745153c/src/Lucene.Net.Core/Util/RamUsageEstimator.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/RamUsageEstimator.cs 
b/src/Lucene.Net.Core/Util/RamUsageEstimator.cs
index 023d3f5..d0fef7d 100644
--- a/src/Lucene.Net.Core/Util/RamUsageEstimator.cs
+++ b/src/Lucene.Net.Core/Util/RamUsageEstimator.cs
@@ -485,6 +485,14 @@ namespace Lucene.Net.Util
                 seen.Add(ob);
 
                 Type obClazz = ob.GetType();
+
+                if (obClazz.Equals(typeof(string)))
+                {
+                    // LUCENENET specific - we can get a closer estimate of a 
string
+                    // by using simple math. Reference: 
http://stackoverflow.com/a/8171099.
+                    // This fixes the TestSanity test.
+                    totalSize += (2 * (((string)ob).Length + 1));
+                }
                 if (obClazz.IsArray)
                 {
                     /*

Reply via email to