@ansamohdsh,
We are currently working on identifying the cause of the error that occurs during the build process of your Dockerfile. We are attempting to reproduce the issue locally.
Could you please provide the Dockerfile or the relevant part of the Dockerfile where the provided script for updating the libgdiplus library is used? The memory leak issue can be resolved by installing the latest version of the libgdiplus library (6.0.5-0xamarin1+ubuntu2004b1), which comes with Mono: https://www.mono-project.com/download/stable/#download-lin
@ansamohdsh,
Our developers have investigated your log and Dockerfile. Based on the provided log, the ttf-mscorefonts-installer package is unavailable. It’s important to note that for Aspose.Slides under aspnet:6.0-7.0, there’s no need to install the libgdiplus library in the Linux environment. This is because, starting from .NET 6.0, Aspose.Slides no longer relies on the libgdiplus library. Microsoft has discontinued support for System.Drawing.Common in the Linux environment beginning with .NET 6.0. Therefore, installing the latest version of the libgdiplus library is unnecessary under .NET 6.0 and .NET 7.0. The previously provided Dockerfile script was developed for .NET 5.0 to update the libgdiplus library, aiming to fix the memory leak issue.
Here is the Dockerfile for .NET 6.0 and .NET 7.0 with some comments:
#FROM mcr.microsoft.com/dotnet/aspnet:6.0-focal AS base
#FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
#FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
#FROM mcr.microsoft.com/dotnet/runtime:7.0 AS base
#Uncomment to install the ttf-mscorefonts-installer for aspnet:6.0 (runtime:6.0) and aspnet:7.0 (runtime 7.0). Please comment it out for aspnet:x.x-focal, as it doesn't work.
RUN echo "deb http://deb.debian.org/debian/ buster main contrib non-free" > /etc/apt/sources.list && \
echo "deb-src http://deb.debian.org/debian/ buster main contrib non-free" >> /etc/apt/sources.list
#The libgdiplus package can be removed if you'd like
RUN apt-get update -q && \
DEBIAN_FRONTEND=noninteractive apt-get install -y -q ttf-mscorefonts-installer fontconfig libgdiplus curl && \
fc-cache -vr
#Install the necessary libraries for Aspose.Slides under .NET 6.0 and .NET 7.0, as they may be missing in the Docker image
RUN apt-get update && apt-get install -y \
libfontconfig1 \
libfreetype6 \
libexpat1 \
libpng16-16
WORKDIR /app
#FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["SomeDLL/SomeDLL.csproj", "SomeDLL/"]
RUN dotnet restore "SomeDLL/SomeDLL.csproj"
COPY . .
WORKDIR "/src/SomeDLL"
RUN dotnet build "SomeDLL.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "SomeDLL.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "SomeDLL.dll"]
Please note that for .NET 6.0 and .NET 7.0 were added the following commands to the Dockerfile:
These commands install the necessary libraries for Aspose.Slides in the Linux environment under .NET 6.0 and .NET 7.0, which may be missing in the docker image.
Updated Dockerfile for .NET 5.0, just in case:
FROM mcr.microsoft.com/dotnet/aspnet:5.0-focal AS base
#FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
#FROM mcr.microsoft.com/dotnet/runtime:5.0 AS base
# Uncomment to install the ttf-mscorefonts-installer for aspnet:5.0 and runtime:5.0. Please comment it out for aspnet:5.0-focal, as it doesn't
#RUN echo "deb http://deb.debian.org/debian/ buster main contrib non-free" > /etc/apt/sources.list && \
#echo "deb-src http://deb.debian.org/debian/ buster main contrib non-free" >> /etc/apt/sources.list
# Update package lists, install the necessary packages and Update font caches
RUN apt-get update -q
ENV DEBIAN_FRONTEND=noninteractive
RUN echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections
RUN apt-get install -y -q ttf-mscorefonts-installer fontconfig curl
RUN fc-cache -vr
# Install the latest version of libgdiplus library for aspnet:5.0, runtime:5.0 and aspnet:5.0-focal to resolve memory leak
RUN apt-get update -q && \
apt-get install -y -q gnupg ca-certificates && \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && \
#Uncomment this code for aspnet:5.0 and runtime:5.0. Comment it out for aspnet:5.0-focal because it doesn't work
#echo "deb https://download.mono-project.com/repo/debian stable-buster main" | tee /etc/apt/sources.list.d/mono-official-stable.list && \
#Uncomment this code for aspnet:5.0-focal. However, you should comment it out for aspnet:5.0 and runtime:5.0, as it doesn't work.
echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | tee /etc/apt/sources.list.d/mono-official-stable.list && \
apt-get update -q && \
apt-get install -y -q libgdiplus
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["SomeDLL/SomeDLL.csproj", "SomeDLL/"]
RUN dotnet restore "SomeDLL/SomeDLL.csproj"
COPY . .
WORKDIR "/src/SomeDLL"
RUN dotnet build "SomeDLL.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "SomeDLL.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "SomeDLL.dll"]
@ansamohdsh,
As for the Sample.pptx file, the memory leak issue has also been fixed. It was tested with 500 iterations of loading and saving the presentation. The average memory consumption during testing ranged from 1 gigabyte to 1.35 gigabytes.
@ansamohdsh,
The memory leak issue occurs under .NET 5.0 in the Linux environment. Under .NET 5.0, Aspose.Slides uses the System.Drawing.Common library, which in turn relies on the libgdiplus library. The libgdiplus library is part of Mono: libgdiplus | Mono. Investigations carried out for this task have revealed that the memory leak occurs in unmanaged memory in the libgdiplus library (version 6.0.4+dfsg-2). However, in version 6.0.5-0xamarin1+ubuntu2004b1, which is currently installed with Mono, the memory leak issue is not observed.
This problem can be reproduced outside of Aspose.Slides under .NET 5.0 by solely using System.Drawing.Common. Here is an example of code that reproduces the memory leak for .NET 5.0 in a Linux environment (the libgdiplus library is installed by default with the libgdiplus package):
for (int i = 0; i < 50; i++)
{
using (Bitmap bmp = new Bitmap(8 * 1024, 8 * 1024))
using (Graphics graphics = Graphics.FromImage(bmp))
{
graphics.Clear(Color.White);
}
}; //-memory allocated for Bitmap is freed, but the memory for the Graphics object is not freed, graphics.Dispose() doesn't work.
In the Dockerfile we provided for .NET 5.0, there have been added some commands to install the latest version of the libgdiplus library (6.0.5-0xamarin1+ubuntu2004b1) from the Mono repository:
# Install the latest version of libgdiplus library for aspnet:5.0, runtime:5.0 and aspnet:5.0-focal to resolve memory leak
RUN apt-get update -q && \
apt-get install -y -q gnupg ca-certificates && \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && \
#Uncomment this code for aspnet:5.0 and runtime:5.0. Comment it out for aspnet:5.0-focal because it doesn't work
#echo "deb https://download.mono-project.com/repo/debian stable-buster main" | tee /etc/apt/sources.list.d/mono-official-stable.list && \
#Uncomment this code for aspnet:5.0-focal. However, you should comment it out for aspnet:5.0 and runtime:5.0, as it doesn't work.
echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | tee /etc/apt/sources.list.d/mono-official-stable.list && \
apt-get update -q && \
apt-get install -y -q libgdiplus
In .NET 6.0/7.0, the memory leak issue does not occur because of Aspose.Slides no longer uses System.Drawing.Common + libgdiplus in the Linux environment. Aspose.Slides uses its own implementation of System.Drawing. Microsoft has discontinued support for System.Drawing.Common on the Linux platform starting from .NET 6.0, and it is now only supported on the Windows platform. More details can be found here: Breaking change: System.Drawing.Common only supported on Windows - .NET | Microsoft Learn.
Yes, it’s fixed for .NET 5.0. There have been added some commands to the Dockerfile to install the latest version of libgdiplus to fix the memory leak. For .NET 6.0/7.0 this issue is not reproduced. For .NET 6.0/7.0 in the Dockerfile, there have been added commands to install necessary libraries used by Aspose.Slides, which may be missing in the Docker image:
#Install the necessary libraries for Aspose.Slides under .NET 6.0 and .NET 7.0, as they may be missing in the Docker image
RUN apt-get update && apt-get install -y \
libfontconfig1 \
libfreetype6 \
libexpat1 \
libpng16-16
The memory leak issue is available for .NET Core 5 in the Linux environment, but it is not available for .NET Core 7.
No, there is no need for that as the memory leak issue is not related to Aspose.Slides.
Note: there are some comments in the Dockerfiles for clarification.
FROM mcr.microsoft.com/dotnet/aspnet:5.0-focal AS base
#FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
#FROM mcr.microsoft.com/dotnet/runtime:5.0 AS base
# Uncomment to install the ttf-mscorefonts-installer for aspnet:5.0 and runtime:5.0. Please comment it out for aspnet:5.0-focal, as it doesn't
#RUN echo "deb http://deb.debian.org/debian/ buster main contrib non-free" > /etc/apt/sources.list && \
#echo "deb-src http://deb.debian.org/debian/ buster main contrib non-free" >> /etc/apt/sources.list
# Update package lists, install the necessary packages and Update font caches
RUN apt-get update -q
ENV DEBIAN_FRONTEND=noninteractive
RUN echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections
RUN apt-get install -y -q ttf-mscorefonts-installer fontconfig curl
RUN fc-cache -vr
# Install the latest version of libgdiplus library for aspnet:5.0, runtime:5.0 and aspnet:5.0-focal to resolve memory leak
RUN apt-get update -q && \
apt-get install -y -q gnupg ca-certificates && \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && \
#Uncomment this code for aspnet:5.0 and runtime:5.0. Comment it out for aspnet:5.0-focal because it doesn't work
#echo "deb https://download.mono-project.com/repo/debian stable-buster main" | tee /etc/apt/sources.list.d/mono-official-stable.list && \
#Uncomment this code for aspnet:5.0-focal. However, you should comment it out for aspnet:5.0 and runtime:5.0, as it doesn't work.
echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | tee /etc/apt/sources.list.d/mono-official-stable.list && \
apt-get update -q && \
apt-get install -y -q libgdiplus
WORKDIR /app
COPY bin/Release/net5.0/publish/ /app/
RUN mkdir obj logs && chown nobody obj logs && apt-get remove -q -y curl
# RUN mkdir obj logs && chown nobody obj logs && apk del curl
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
# USER nobody
ENTRYPOINT ["dotnet", "Sample.dll"]
#FROM mcr.microsoft.com/dotnet/aspnet:6.0-focal AS base
#FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
#FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
#FROM mcr.microsoft.com/dotnet/runtime:7.0 AS base
#Uncomment to install the ttf-mscorefonts-installer for aspnet:6.0 (runtime:6.0) and aspnet:7.0 (runtime 7.0). Please comment it out for aspnet:x.x-focal, as it doesn't work.
RUN echo "deb http://deb.debian.org/debian/ buster main contrib non-free" > /etc/apt/sources.list && \
echo "deb-src http://deb.debian.org/debian/ buster main contrib non-free" >> /etc/apt/sources.list
#The libgdiplus package can be removed if you'd like
RUN apt-get update -q && \
DEBIAN_FRONTEND=noninteractive apt-get install -y -q ttf-mscorefonts-installer fontconfig libgdiplus curl && \
fc-cache -vr
#Install the necessary libraries for Aspose.Slides under .NET 6.0 and .NET 7.0, as they may be missing in the Docker image
RUN apt-get update && apt-get install -y \
libfontconfig1 \
libfreetype6 \
libexpat1 \
libpng16-16
WORKDIR /app
COPY bin/Release/net7.0/publish/ /app/
RUN mkdir obj logs && chown nobody obj logs && apt-get remove -q -y curl
# RUN mkdir obj logs && chown nobody obj logs && apk del curl
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
# USER nobody
ENTRYPOINT ["dotnet", "Sample.dll"]
@ansamohdsh,
We’ve conducted a series of tests under .NET 7.0 using the presentations (DiagnosticReportExportTemplate.pptx and Sample.Pptx) you provided, and the previously supplied code sample. Unfortunately, the memory leak is not reproduced as a result of the testing. Could you please provide a sample project (code) and a presentation that reproduces the issue?
It was performed 1000 iterations of loading and saving the presentation both in single-threaded and multi-threaded modes. Memory consumption in the multi-threaded mode ranged from 1.7 to 4.5 GB (10 threads were simultaneously loading and saving presentations). During the testing process, memory usage increased very slowly – by +100 MB after every 100 iterations of loading and unloading presentations. However, this issue is also resolved by invoking the garbage collector via GC.Collect, and memory consumption stabilizes, staying in the range of 1.7-4.5 GB without any increases in the upper consumption limit.
Does memory consumption increase steadily over time, and does it eventually consume all available memory, leading to the application crashing due to memory exhaustion?
@andrey.potapov We are working on a POC where we will replicate the issue by showcasing how we create the components in our ppt.
Please allow us few more day and we will get back to you soon.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.