C
C#TOKYODRIFT!

❔ dataset memory leak

I found memory leak and I don't understand how to fix it Test case:
public class MemoryLeaksTest
: AsyncDisposable
{
private readonly FastReport.Report _report;
private readonly ReportOutputParameters _outputParameters;

private const string ReportPath = "ByRequests.frx";

public MemoryLeaksTest()
{
_report = new();

_report.Load( ReportPath );

_outputParameters = new()
{
Format = ReportOutputFormatType.PDF
};
}

protected override void Dispose( bool disposing )
{
if ( disposing )
_report.Dispose();

base.Dispose( disposing );
}

public async Task Run( bool export )
{
using var dataSet = await FillDataSet();

RegisterReportWithDataSet( dataSet );
PrepareReport();

if ( export )
ExportReport();
}

private void ExportReport()
{
_report.Export(
_outputParameters,
$"test_exported_report_{Guid.NewGuid()}" );

Console.WriteLine( @"report was exported" );
}

private void PrepareReport()
{
_report.Prepare();
}

private void RegisterReportWithDataSet( ByRequests dataSet )
{
_report.RegisterData( dataSet );
}

private async Task<ByRequests> FillDataSet()
{
var dataSet = new ByRequests();

for ( var i = 0; i < 1_000_000; i++ )
{
dataSet._ByRequests.AddByRequestsRow(
Status: $"status: {i}",
Visitor: $"visitor {i}",
Operator: $"operator {i}",
HostSubject: $"host_subject {i}",
CreationTime: $"creation_time {i}",
Validity: $"validity {i}",
Number: $"{i}" );

if ( i % 10000 == 0 )
Console.WriteLine( @$"progress: {i / 10000}" );
}

return dataSet;
}
}
public class MemoryLeaksTest
: AsyncDisposable
{
private readonly FastReport.Report _report;
private readonly ReportOutputParameters _outputParameters;

private const string ReportPath = "ByRequests.frx";

public MemoryLeaksTest()
{
_report = new();

_report.Load( ReportPath );

_outputParameters = new()
{
Format = ReportOutputFormatType.PDF
};
}

protected override void Dispose( bool disposing )
{
if ( disposing )
_report.Dispose();

base.Dispose( disposing );
}

public async Task Run( bool export )
{
using var dataSet = await FillDataSet();

RegisterReportWithDataSet( dataSet );
PrepareReport();

if ( export )
ExportReport();
}

private void ExportReport()
{
_report.Export(
_outputParameters,
$"test_exported_report_{Guid.NewGuid()}" );

Console.WriteLine( @"report was exported" );
}

private void PrepareReport()
{
_report.Prepare();
}

private void RegisterReportWithDataSet( ByRequests dataSet )
{
_report.RegisterData( dataSet );
}

private async Task<ByRequests> FillDataSet()
{
var dataSet = new ByRequests();

for ( var i = 0; i < 1_000_000; i++ )
{
dataSet._ByRequests.AddByRequestsRow(
Status: $"status: {i}",
Visitor: $"visitor {i}",
Operator: $"operator {i}",
HostSubject: $"host_subject {i}",
CreationTime: $"creation_time {i}",
Validity: $"validity {i}",
Number: $"{i}" );

if ( i % 10000 == 0 )
Console.WriteLine( @$"progress: {i / 10000}" );
}

return dataSet;
}
}
T
TOKYODRIFT!398d ago
Console.CancelKeyPress += ( _, _ ) =>
{
Console.Write( @"Exiting" );
Environment.Exit( 0 );
};

var runner = new MemoryLeaksTest()
.Run( export: false );

runner.Dispose();

while ( Console.ReadKey().Key != ConsoleKey.Escape )
{

}
Console.CancelKeyPress += ( _, _ ) =>
{
Console.Write( @"Exiting" );
Environment.Exit( 0 );
};

var runner = new MemoryLeaksTest()
.Run( export: false );

runner.Dispose();

while ( Console.ReadKey().Key != ConsoleKey.Escape )
{

}
T
TOKYODRIFT!398d ago
T
TOKYODRIFT!398d ago
I don't understand why but memory doesn't сlear even if I use dispose
T
TOKYODRIFT!398d ago
A
Angius398d ago
First time I see AsyncDisposable class instead of IAsyncDisposable interface
T
TOKYODRIFT!398d ago
I dont think its a problem blobthumbsup
A
Accord397d ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
❔ WebAPI .NET 7.0 - Encrypt connectionstring in appsettings.jsonguys, I'm writing some WebAPI using .NET 7.0, and I'd like to secure the connectionstring with encry❔ how to read strings correctly with System.Data.SQLitei m trying read turkish characters from database but i can't see correctly❔ Blazor server app, base url / base page to set environmentHi 🙂 I have a Blazor Server app, where I would like to use some dynamic baseurl. Say instead of my❔ C# Console Application -its only writing the same random string, how can i make it do different ones?❔ Rapid prototypingDo you feel there is such a thing as rapid prototyping or mvp development where you do things differ❔ HotChocolate with IQueryable, apply a required filter on the ef entityBasically, I'm trying to find a way to configure an `IObjectFieldDescriptor` by adding a required ar❔ Dev/prod databseHello, Me and a friend wants to create a webb-app project with a react frontend and C# backend. ❔ Book recommendation to learn c#/dotnetI've been programming in python for a little under two years. I am starting a new job in c#. Whats a❔ Use `this` inside method decoratorTried to follow https://stackoverflow.com/a/2966758 ```cs [AttributeUsage(AttributeTargets.Metho✅ How can I make VSCode auto add semicolons to statements on save?I'm coming from the world of Javascript and Typescript. There, you can just use Prettier to automati❔ Find common substring at start of every string in listI have a list of Windows path strings and I want to determine the common beginning shared by all of ❔ Code is completely skipping over an areaI'm writing a script for a game where if you don't press Spacebar within 4 seconds, the number of fa❔ Registering an extracted appx package```csharp public static void RegisterMinecraftAppxPackage(string appxPackagePath) { try { ✅ Exception Handling for NRE without modifying every call.I have a ReadData function which reads the memory of a process. If the process exits or crashes duri✅ please help idk what to do or what i didSeverity Code Description Project File Line Suppression State Error Project❔ Better user experience inputting commandsHow would I get input from a user, the fancy way? What I mean is that for example when a user types ❔ Return in the middle of a methodIs it ok? I think that it improves readability and performance, but a professor I know argues that i❔ Can't build a MSIX Package for a WPF app