We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Saving CAD Image causes error in Linux docker container (C# .NET Core)

I am running a .NET Core Web API in a Linux Docker container and receive this error: “Requested 1030124 bytes. Maximum size for region is 262144 bytes.” when trying to call .Save() on a CADImage.

This only happens in the Linux container but works fine when running normally through Visual Studio in Windows.

Here is the code saving the image:

        private readonly CadImage _img;

        var rasterizationOptions = new Aspose.CAD.ImageOptions.PngOptions()


            VectorRasterizationOptions = new CadRasterizationOptions()


                PageHeight = newSize,

                PageWidth = newSize,

                Zoom = 1.0f,


                DrawType = CadDrawTypeMode.UseObjectColor,

                Layouts = new string[] { SelectedLayout },

                GraphicsOptions = new GraphicsOptions()


                    TextRenderingHint = TextRenderingHint.AntiAlias,


                ExportAllLayoutContent = false,



        var stream = new MemoryStream();

        _img.Save(stream, rasterizationOptions);

When changing the PageHeight and PageWidth options to smaller numbers (this errors out when PageHeight and PageWidth are 16000) the error goes away.

Please let me know of any information you may need from me to get this issue resolved.


I have observed the issue shared by you. I suggest you to please try using latest Aspose.CAD for .NET 20.4 on your end. I have also observed your following comments:

This means that memory available to render the file that you are using is lesser then desired. So, when you reduce the page size, you are actually reducing the output image that you are trying to render in memory and therefore you are able to render successfully. Can you please increase the memory on your end? In case there is still an issue then please share the working sample project along with source file and memory profile on your docker. We will be able to proceed further on our end on provision of requested information.

The amount of memory the container has access to was originally 2GB and I increased it to 4GB and received the same message, which would imply that it has nothing to do with the actual memory available.

I ran the free command in the container and these are the results:

free -m
              total        used        free      shared  buff/cache   available
Mem:           3940         303        3295           1         341        3430
Swap:          1023           0        1023

I have updated to Version 20.5.0 of the library and see the same issue.

The warning appears to be more of an error since it actually causes the process to terminate which then shuts down the container.

The program exits with exited with code 139 which appears to say that…

Your program tried to make a memory access to a place it had no permissions for, so the operating system killed it

In this instance it would appear that the library has made this call to memory it does not own.

Here is a small app that is having the same issue.

To build use: docker build -t crashing-dwg .

To run use: docker-compose up

CrashingDwg.zip (346.1 KB)


I have considered the details and memory profile shared by you. We need to further investigate the issue on our end and a ticket with ID CADNET-1123 has been created in our issue tracking system to investigate it further. We will share updates with you as soon as issue will be fixed.

I need to request that this be moved to our paid support forums because of it’s criticality during our release plan.

Thank you,


You have to create a separate request in Priority support helpdesk for expediting the issue. You can share the ticket ID CADNET-1123 there for reference.

The issues you have found earlier (filed as CADNET-1123) have been fixed in this update.