Memory not freed
I put an Image on FRX, Request ‘TestReport’ multiple times,My container footprint is 1GB or higher. Is there a problem with my code?
[Route("/TestReport")]
public string TestPrint(string type)
{
using Report report = new Report();
report.Load("3.frx");
using FileStream fs = new FileStream("1.png", FileMode.Open, FileAccess.Read);
byte[] buffur = new byte[fs.Length];
fs.Read(buffur, 0, (int)fs.Length);
fs.Close();
using ImageExport image = new ImageExport();
image.ImageFormat = ImageExportFormat.Jpeg;
image.Resolution = 300;
var data = new List<object>() { new { Image = buffur } };
report.RegisterData(data, "Test");
report.Prepare();
using MemoryStream reportImageStream = new MemoryStream();
report.Export(image, reportImageStream);
return Convert.ToBase64String(reportImageStream.ToArray());
}
There also seems to be a container exit issue under concurrent requests.
Hi,
Tell more about your testing environment (Linux, Windows). Could you show your Dockerfile?
@fediachov I pushed the image I was using to DockerHub https://hub.docker.com/r/qq709821512/hq
Hi, What version of FastReport OpenSource do you use? I can't reproduce memory leak and problem with concurrent requests in container in version 2021.3.17.
@0legK Is there something wrong with my container?
My container state

Is there something wrong with my container?
I don't think so. I have tested you application https://github.com/BlackPig-dev/TestFastReport I just updated the versions: FastReport.OpenSource to 2021.3.17 and FastReport.Compat to 2021.2.10
My code uses the version of 2021.3.17
<ItemGroup>
<PackageReference Include="FastReport.OpenSource" Version="2021.3.17" />
</ItemGroup>
Is there something wrong with my image? Something to do with libgdiplus?
I need time to check it again. I'll let you know later.
@0legK Thanks a lot
Hi,
I have tested it again. I have not find any memory leaks in Image export of FastReport OpenSource. And I have not find memory leaks when report preparing. Also I don't see any problems in your test applicaton.
About memory consumption. It grows every time when page refreshes. Sometimes memory consumption grows down. When page closes, all memory going freed up.
It looks like usual work of GC. GC runs from time to time when system is not loaded. And when there is a lack of memory.
@0legK I just manually refreshed the page frequently with F5, and the memory was already high without even using the stress test tool
https://user-images.githubusercontent.com/28700143/127590246-03d87da2-db77-48c1-bb46-e2b630eba418.mp4
@0legK @fediachov I wonder if you have started to deal with this problem.
The problem could be with libgdiplus. It does not reproduce on all systems and versions of this library. For example. Could you test this solution?
@Ramoshuai I tried the solution and it works fine the container memory went down to ~200MB
This is my current Dockerfile, may be it can be better but this is what worked with me.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
RUN apt-get update && apt-get install -y --allow-unauthenticated libc6-dev libgdiplus libx11-dev
RUN apt-get install -y libgif-dev autoconf libtool automake build-essential gettext libglib2.0-dev libcairo2-dev libtiff-dev libexif-dev libpango1.0-dev git
WORKDIR /var/customLib
RUN git clone https://github.com/mono/libgdiplus.git
WORKDIR /var/customLib/libgdiplus
RUN ./autogen.sh --with-pango --prefix=/usr
RUN make
RUN make install
WORKDIR /app
EXPOSE 80
@ElBedeawi @fediachov I tried to recompile the environment again, but still the same I uploaded my code here my code Under concurrent requests, the memory still quickly rose to 1G
Hi,
We have fixed some memory leaks. Please, try latest version 2021.4.16. I hope it can be better.
Hi,
We have fixed some memory leaks. Please, try latest version 2021.4.16. I hope it can be better.
The version I use is the latest 2021.4.16
<PackageReference Include="FastReport.OpenSource" Version="2021.4.16" />
Hi, we are experienceing the same behaviour with version 2022.2.12. This only happends in linux env, not in windows.
Can anyone confirm if @ElBedeawi solution works? Is it a problem with libgdiplus?
Regards
Hi, we are experienceing the same behaviour with version 2022.2.12. This only happends in linux env, not in windows.
Can anyone confirm if @ElBedeawi solution works? Is it a problem with libgdiplus?
Regards
I haven't tried the latest version yet, but for the version I'm using "2021.4.13" it was the issue and building it using that dockerfile worked fine for me.
Ok, I can confirm that in our case, what @ElBedeawi said solved the memory problem.
Thank you very mutch!