Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4D4EB200C42 for ; Sat, 11 Mar 2017 06:52:57 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 4C02E160B79; Sat, 11 Mar 2017 05:52:57 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 7149D160B90 for ; Sat, 11 Mar 2017 06:52:56 +0100 (CET) Received: (qmail 89607 invoked by uid 500); 11 Mar 2017 05:52:55 -0000 Mailing-List: contact commits-help@lucenenet.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@lucenenet.apache.org Delivered-To: mailing list commits@lucenenet.apache.org Received: (qmail 89002 invoked by uid 99); 11 Mar 2017 05:52:54 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Mar 2017 05:52:54 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 66559E69B1; Sat, 11 Mar 2017 05:52:54 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: nightowl888@apache.org To: commits@lucenenet.apache.org Date: Sat, 11 Mar 2017 05:53:03 -0000 Message-Id: <2b1520b09d324ec78d948fc010c2912d@git.apache.org> In-Reply-To: <75e1298c4e0e487e851d067db21f0fc5@git.apache.org> References: <75e1298c4e0e487e851d067db21f0fc5@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [10/16] lucenenet git commit: 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. archived-at: Sat, 11 Mar 2017 05:52:57 -0000 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 Authored: Fri Mar 10 21:54:33 2017 +0700 Committer: Shad Storhaug 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) { /*