Forums

Welcome Guest Search | Active Topics | Members

Memory leak Options
amf
Posted: Sunday, January 13, 2008 8:36:53 AM
Rank: Member
Groups: Member

Joined: 10/1/2006
Posts: 10
Points: 12
I'm seeing a major memory issue with GM (both 3.5 and 4.5).

Here's some sample code to show the problem:

Code:

    Public Function ScalePictureToMemory(ByVal img() As Byte, ByVal ext As String) As Byte()

        ' since it's going into a word doc, make it max resolution of 150 dpi in both directions
        ' and a max width of 7.5 inches and a max height of 10 inches.
        Dim strm As New System.IO.MemoryStream(img)
        Dim bitmap As New Aurigma.GraphicsMill.Bitmap(strm)

        Dim height As Integer = bitmap.Height
        Dim width As Integer = bitmap.Width
        Dim sizeX As Single = (width / bitmap.HorizontalResolution)
        Dim sizeY As Single = (height / bitmap.VerticalResolution)
        Dim maxReduction As Single = 1
        If sizeX > 7.5 Then maxReduction = Math.Min(maxReduction, 7.5 / sizeX)
        If sizeY > 10 Then maxReduction = Math.Min(maxReduction, 10 / sizeY)

        Dim outStrm As New MemoryStream
        Dim results() As Byte
        Try
            Dim maxXResolution = Math.Min(bitmap.HorizontalResolution, 150)
            Dim maxYResolution = Math.Min(bitmap.VerticalResolution, 150)
            If maxReduction < 1 Or bitmap.HorizontalResolution > 150 Or bitmap.VerticalResolution > 150 Then
                ' needs reduction and/or lossy compression
                bitmap.HorizontalResolution = maxXResolution
                bitmap.VerticalResolution = maxYResolution
                bitmap.Transforms.Resize(sizeX * maxReduction * maxXResolution, sizeY * maxReduction * maxYResolution, Aurigma.GraphicsMill.Transforms.ResizeMode.Resize, InterpolationMode.HighQuality)

                bitmap.Save(outStrm, New JpegEncoderOptions)
                Return outStrm.ToArray()
            ElseIf ext.ToLower.EndsWith("jpg") Or ext.ToLower.EndsWith("jpeg") Then
                ' small enough AND jpeg already
                Return img
            Else
                ' small enough, but let's try to make it smaller by making it lossy
                bitmap.Save(outStrm, New JpegEncoderOptions)
                Return outStrm.ToArray()
            End If
        Finally
            'bitmap.Dispose()
            strm.Close()
            outStrm.Close()
            bitmap.Dispose()
        End Try
    End Function


The loop to run the code is this:

Code:

        Dim imageData() As Byte = <the contents from a jpg file>
        For i As Integer = 0 To 200000
            If i Mod 100 = 0 Then
                Console.WriteLine(i)
            End If
            Dim newImage(imageData.Length - 1) As Byte
            imageData.CopyTo(newImage, 0)
            Dim img() As Byte = ScalePictureToMemory(newImage, ".jpg")
        Next


I can run the program with a 170K jpg file and the loop gets to around 7000 before my system runs out of memory. What appears to be happening is that something in GM is holding onto the memorystream, which in turn is holding onto the bytes in the variable newImage (170K of them). I have GM 3.5 and it's in there as well as the 4.5 eval I downloaded. Help?
Alex Kon
Posted: Thursday, January 17, 2008 3:56:38 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 1/31/2005
Posts: 385
Points: 400
Hello,

Sorry for delay, but I just wanted to be sure in our results. It is very strange, but we cannot reproduce this issue in our tests. However this is very important message for us and we will continue testing.

Please submit case with complete test application which reproduces the issue with the sample image ?


Best wishes, Alex.
amf
Posted: Thursday, January 17, 2008 4:05:35 AM
Rank: Member
Groups: Member

Joined: 10/1/2006
Posts: 10
Points: 12
I forgot to mention, this is using .NET 1.1. Does that change your testing?
Alex Kon
Posted: Thursday, January 17, 2008 4:46:42 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 1/31/2005
Posts: 385
Points: 400
Hello,

No, it seems that NET 1.1 version also works correctly.

Do you have any differences between NET 2.0 and NET 1.1 behaviour in your tests? Could you send us sample file & project? Maybe I just missed something...


Best wishes, Alex.
sviluppophotosi
Posted: Wednesday, February 06, 2008 12:55:10 AM
Rank: Newbie
Groups: Member

Joined: 2/6/2008
Posts: 9
Points: 27
We have the same problem here, we load a lot of bitmaps and every time we dispose all the bitmap after we use it. But some times we get "unable to commit memory" without any reason.

Any news about this issue?
Alex Kon
Posted: Wednesday, February 06, 2008 6:16:18 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 1/31/2005
Posts: 385
Points: 400
Hello,

Which version of the Graphics Mill for .NET do you use? Please, try to install the latest version 4.5.17 and let me know whether the problem can be reproduced with it.



Best wishes, Alex.
meriturva
Posted: Wednesday, February 06, 2008 12:40:19 PM
Rank: Newbie
Groups: Member

Joined: 2/5/2008
Posts: 6
Points: 18
we are going to test the new version....i will inform you if it will appens again.
Thanks!

Meriturva
Alex Kon
Posted: Thursday, February 07, 2008 1:52:36 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 1/31/2005
Posts: 385
Points: 400
OK, I will be looking forward for your answer.

Best wishes, Alex.
sviluppophotosi
Posted: Friday, February 15, 2008 4:58:49 AM
Rank: Newbie
Groups: Member

Joined: 2/6/2008
Posts: 9
Points: 27
We had this issue again.
We have checked and we dispose every objects. We actually use bitmaps, pdfframes and pdfwriters.

How to give you more information about it?

we just have so many memory used by the application and if we use a memory profiler utility and we didn't see any strange memory consuption.

We use the last version (4.5.17) of graphmill.net framework 2

Meriturva

Alex Kon
Posted: Friday, February 15, 2008 5:54:26 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 1/31/2005
Posts: 385
Points: 400
Hello,

Could you provide us with more information about usual memory consumption of your application, how many files do you process, which objects and classes do you use when the issue appears?

And sample project which illustrates the issue - that would be really great!

If it is not acceptable for you to publish this information here, feel free to submit case.



Best wishes, Alex.
meriturva
Posted: Friday, February 15, 2008 3:58:36 PM
Rank: Newbie
Groups: Member

Joined: 2/5/2008
Posts: 6
Points: 18
we had a long session here with so many tests and different approach to take more information about the libraries we use.
Seems that now we have found the issue.
it was related no to your great library but with the itextshart library and one specific approach to merge different pdf. now we use a more simple approach with the class PdfCopy and the method freeReader.

We use iThetSharp because we didn't find a way to do it with your library. we need just to merge different pdfs. are you planing to push up the pdf functionality (read and write) on the future of the graphMill? i mean, will be great to have an add-on just to handle pdf files...even if we have to pay for the add.on!

Any way thanks so much for the product and the support....it is money well spent!

thanks.
Meriturva

Dmitry
Posted: Monday, February 18, 2008 11:54:49 PM
Rank: Advanced Member
Groups: Administration , Member

Joined: 8/3/2003
Posts: 458
Points: 204
Thanks for getting us to know about real reason of the problem.
Graphics Mill for .NET has the ability to construct PDF from images. Unfortunately read capability is not supported. We have plans to add this functionality in the future but now I cannot tell you what version of Graphics Mill will have this functionality.


Sincerely yours,
Dmitry Sevostjanov.
meriturva
Posted: Thursday, February 21, 2008 1:36:12 AM
Rank: Newbie
Groups: Member

Joined: 2/5/2008
Posts: 6
Points: 18
i'm really sorry but now we have more information about this issue, and it is related to your library or a bad use by us.

The memory is not released after we use the pdf functionality from your graphmill.net, we use to save pdf to share network directory.

Here a sample code we use:

Code:
_pdfWriter = new PdfWriter(page.FileName);
PdfFrame pdfFrame = new PdfFrame(pageBitmap, p.Quality);
_pdfWriter.AddFrame(pdfFrame);
pdfFrame.Dispose();

if (pageBitmap != null)
         pageBitmap.Dispose();
         pageBitmap = null;
}


After we append some pages we close the pdfwriter:

Code:
if (_pdfWriter != null)
            {
                _pdfWriter.Close();
                _pdfWriter.Dispose();
                _pdfWriter = null;
            }


after that we have a memory amount consumed from the application near the size of the finale pdf, so i think that the stream or the byte[] of the pdfWriter file is not relased.
So do you have an idea about it?

Thanks
Meriturva
meriturva
Posted: Thursday, February 21, 2008 11:57:18 PM
Rank: Newbie
Groups: Member

Joined: 2/5/2008
Posts: 6
Points: 18
no news about this issue?

please we just would like to have a confirmation or an help to use in the right way the pdf feature from your library.

Thanks
Meriturva
Alex Kon
Posted: Friday, February 22, 2008 12:42:51 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 1/31/2005
Posts: 385
Points: 400
Hi,

You code is correct - it is our issue for sure. Our team is already working on it and this fix will be included in the next release of Graphics Mill for .NET.

Please, could you submit case so we can notify you when the issue will be fixed?



Best wishes, Alex.
meriturva
Posted: Monday, February 25, 2008 12:28:50 AM
Rank: Newbie
Groups: Member

Joined: 2/5/2008
Posts: 6
Points: 18
any news about that issue?

thanks
Meriturva
Andrew
Posted: Thursday, February 28, 2008 4:45:39 AM

Rank: Advanced Member
Groups: Administration , Member

Joined: 8/2/2003
Posts: 708
Points: 105
Guys have fixed it yesterday. Here is a link for updated DLLs:

http://www.aurigma.com/Download/Temp/GraphicsMill45_20080227.zip

Also we will include this fix into the nearest update.

Sincerely yours,
Andrew Simontsev from Aurigma Team
Luis Delgado
Posted: Thursday, February 28, 2008 9:37:26 AM
Rank: Member
Groups: Member

Joined: 12/6/2007
Posts: 5
Points: 9
Hi,

I replaced the existing DLLs from the installation directory with the ones above. Then I removed the existing references in my project and added them again. When I tried to recompile the project it fails. It says it cannot find the Aurigma namespace. When I replaced the libraries I did notice a version change in VS2005. Aurigma.GraphicMill.dll was displayed as version 4.5.23 (previous was 4.5.17).

Am I doing something wrong?

Thanks Luis
Luis Delgado
Posted: Thursday, February 28, 2008 10:15:50 AM
Rank: Member
Groups: Member

Joined: 12/6/2007
Posts: 5
Points: 9
Never mind. I forgot to replace the reference in another project within the solution so it created a conflict. I replaced the libraries in all the necessary projects and everything worked fine.

Luis
Dmitry
Posted: Thursday, February 28, 2008 10:21:46 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 8/3/2003
Posts: 458
Points: 204
Thank you, Luis.

Do not hesitate to contact our team in case of any problems or difficulties. We will be happy to assist you.

Sincerely yours,
Dmitry Sevostjanov.
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Yet Another Forum.net version 1.9.1.6 running under Cuyahoga.
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.