Welcome Guest Search | Active Topics | Members

Unable To Write Data to Stream Options
JRumerman
Posted: Thursday, December 06, 2007 2:29:41 PM
Rank: Member
Groups: Member

Joined: 12/6/2007
Posts: 7
Points: 6
Hi everyone,

I was wondering if anybody could take a look at this error message and throw out an idea of why it's happening.

Thx, Joel

Code:

Source:

Aurigma.GraphicsMill

Description: Unable to write data to stream. ;

Stack:    at Aurigma.GraphicsMill.Codecs.FormatWriter._Close()     at Aurigma.GraphicsMill.Codecs.FormatWriter.Dispose(Boolean disposing)     at Aurigma.GraphicsMill.SyncHandler.Dispose()     at Aurigma.GraphicsMill.Codecs.FormatWriter.Dispose()     at Aurigma.GraphicsMill.Bitmap.Save(Stream stream, IEncoderOptions options)  ...
Alex Kon
Posted: Friday, December 07, 2007 12:11:30 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 1/31/2005
Posts: 386
Points: 403
Hi Joel,

You are the first with such issue and I have to say that cannot even imagine what caused this error. Could you provide us with more details?

1) What output stream do you use?
2) How large the image which you are trying to save, in which file format?
3) Does the error occurs every time, or from time to time?

And it would be great to receive code sample which reproduces the problem.

Best wishes, Alex.
JRumerman
Posted: Friday, December 07, 2007 11:24:05 AM
Rank: Member
Groups: Member

Joined: 12/6/2007
Posts: 7
Points: 6
Hi Alex,

We found what was causing the "unable to write data to stream" error. It was an error on our part.

However, we are seeing what we believe is a memory leak when the Save fails.

Here's our code:
Code:

for (int i = 0; i < 1000; i++)
            {
                try
                {
                    using (FileStream fs = new FileStream("C:\\06-0000313236-03-05_20070904212918847.jpg", FileMode.Open))
                    {
                        Byte[] bytes = new Byte[fs.Length];
                        fs.Read(bytes, 0, int.Parse(fs.Length.ToString()));

                        using (MemoryStream ms = new MemoryStream(bytes))
                        using (Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(ms))
                        {
                            int iImgHeight = bitmap.Height;
                            int iImgWidth = bitmap.Width;
                            if (bitmap.IsCmyk)
                            {
                                using (Aurigma.GraphicsMill.Transforms.PixelFormatConverter pixelConverter = new Aurigma.GraphicsMill.Transforms.PixelFormatConverter())
                                {
                                    pixelConverter.DestinationPixelFormat = Aurigma.GraphicsMill.PixelFormat.Format32bppArgb;
                                    pixelConverter.ApplyTransform(bitmap);
                                    bitmap.Save(ms, new Aurigma.GraphicsMill.Codecs.JpegEncoderOptions(100, false));
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    ex.ToString();
                }
            }


Attached is the image that we're using to test.

An exception occurs on the Save (which is ok for right now as that's what we're testing), but we're not seeing the memory released through the automatic calling of the Dispose method by the using statement. To double check we wrote the using statement as a try/catch/finally block and saw the same results.

We also tested adding a GC.Collect in the exception handler to force the GC to collect, but didn't see any improvement.

The leak isn't huge, but it's steady ~300K a call.

We think the leak is happening because Aurigma.GraphicsMill.StreamWrapper associated to the Bitmap isn't being disposed of properly. That's what our MemoryProfiling is showing us at least.

We're seeing the number of instances of System.Byte[], System.IO.MemoryStream, and Aurigma.GraphicsMill.StreamWrapper grow by the number of loop iterations.

Do you see anything that we're doing wrong and if you agree that there's a memory leak on your end, do you have a work around?

Thx, Joel


JRumerman attached the following image(s):
06-0000313236-03-05_20070904212918847.jpg

Alex Kon
Posted: Monday, December 10, 2007 3:34:12 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 1/31/2005
Posts: 386
Points: 403
Hello Joel,

Yes, we confim the issue. It will be fixed in the next release. If this problem is critical for you, please submit case and we will provide you with the update.

Best wishes, Alex.
JRumerman
Posted: Monday, December 10, 2007 9:00:35 AM
Rank: Member
Groups: Member

Joined: 12/6/2007
Posts: 7
Points: 6
Hi Alex,

Thanks for confirming that this was a known issue and there is a patch available. I will be contacting support for the patch. This is pretty critical for us.

R, Joel
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.