wbish/jsondiffpatch.net

Exception of type 'System.OutOfMemoryException' was thrown using - JsonDiffPatch()

devanathan2017 opened this issue · 1 comments

Hi ,

I have two list lstA(33727 records) and lstB(34238 records). Converting those as json string and trying to compare using JsonDiffPatch. code below

lstA = GetRateCard();
lstB = rates.Meters.ToList();

var first = JsonConvert.SerializeObject(lstA);
var second = JsonConvert.SerializeObject(lstB);

var jdp = new JsonDiffPatch();
var output = jdp.Diff(first, second); ----->>> getting the out of memory exception screen shot also attached.

error

stack trace:
at JsonDiffPatchDotNet.Lcs.LcsInternal(List1 left, List1 right) in c:\Dev\wbish_github\jsondiffpatch.net\Src\JsonDiffPatchDotNet\Lcs.cs:line 31
at JsonDiffPatchDotNet.Lcs.Get(List1 left, List1 right) in c:\Dev\wbish_github\jsondiffpatch.net\Src\JsonDiffPatchDotNet\Lcs.cs:line 24
at JsonDiffPatchDotNet.JsonDiffPatch.ArrayDiff(JArray left, JArray right) in c:\Dev\wbish_github\jsondiffpatch.net\Src\JsonDiffPatchDotNet\JsonDiffPatch.cs:line 399
at JsonDiffPatchDotNet.JsonDiffPatch.Diff(JToken left, JToken right) in c:\Dev\wbish_github\jsondiffpatch.net\Src\JsonDiffPatchDotNet\JsonDiffPatch.cs:line 54
at JsonDiffPatchDotNet.JsonDiffPatch.Diff(String left, String right) in c:\Dev\wbish_github\jsondiffpatch.net\Src\JsonDiffPatchDotNet\JsonDiffPatch.cs:line 276
at DomainOperations.RateOperations.DailyRates(DataResponse rates) in E:\Cloud Service Providers Project\BILLINGAPI\DomainOperations\RateOperations.cs:line 308

However if i try with few records saw 2000 each i am able see the expected results. not sure how to deal with more data ? need help

Thanks
Dev.

wbish commented

Hey @devanathan2017 a workaround to unblock you would be to do:

var options = new Options();
options.ArrayDiff = ArrayDiffMode.Simple;
var jdp = new JsonDiffPatch(options)

I'll have to take a deeper look to see what we can do in the mean time about the default behavior.