CrystalReportViewer 2008 does not release GDI objects after closing.

We need help in resolving an issue with a WinForms application we have developed that makes use of the Crystal Reports 2008 viewer control to both generate reports based on various parameters the user supplies and to view these same reports having been previously saved in crystal 2008 format.
The issue we are seeing is that GDI objects are being created during the report generation process but some are not being released when the report viewer window is closed down. This leads to the system running out of GDI objects (seen by using the Windows task manager) and ultimately the application crashes. It is only when the application is closed completely that GDI resources are returned to the system.
In an effort to isolate the cause of this problem we created a much simplified WinForms application that simply allowed us to systematically open and close a WinForm  that contains a CrystalReportViewer  to display one of our example reports. We found that the behaviour is the same for this application too.
Browsing the crystal reports forums reveals there have been a few questions about u201Cmemory leaksu201D like this (see "Thread: CrystalReportViewer memory usage increases until out of memory" as an example) and there has been a good deal of talk about manually "disposing" of report documents and viewers but trying this does not correct this issue
The extent of the "GDI Object leak" does depend upon the kind of report that is pulled in. One report we have that is 360 pages long and contains graphs and tables of data leaks 390 object per test iteration.
Is this a known issue with the Crystal Report Viewer and if so is there an update or a workaround available?
Are we performing all the correct initialisation prior to using the viewer? For example we are supplying the report to the viewer through a ReportDocument object; is there something special we need to do with that?
Do we have to do anything special when closing the viewer?
Could it be to do with the design of our reports? We are using the Crystal Reports 2008 editor (sp1) to do this design.
We urgently need to help in understanding why this is happening and to be able implement a solution that will address this problem.
I have provided the following code snippets of this sample application to give a flavour of what we are doing and hopefully you can see that it is not complex. The example shows the crystal viewer being presented with a ReportDocument as a Report Source ... this is how our proper application does things but if you try supplying the filename of the crystal report directly, the problem is the same.
This C# code was written using Visual Studio 2008.
// ===================================================================================
//                                                  Sample Code Snippets  
// ===================================================================================
    static class Program
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MDIParent1());
// ===================================================================================
// ===================================================================================
    public partial class MDIParent1 : Form
        private int childFormNumber = 0;
        public MDIParent1()
            InitializeComponent();
        private void ShowNewForm(object sender, EventArgs e)
            Form childForm = new TestForm();
            childForm.MdiParent = this;
            childForm.Text = "Window " + childFormNumber++;
            childForm.Show();
        private void OpenFile(object sender, EventArgs e)
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            openFileDialog.Filter = "Text Files (.txt)|.txt|All Files (.)|.";
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
                string FileName = openFileDialog.FileName;
        private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            saveFileDialog.Filter = "Text Files (.txt)|.txt|All Files (.)|.";
            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
                string FileName = saveFileDialog.FileName;
        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
            this.Close();
        private void CutToolStripMenuItem_Click(object sender, EventArgs e)
        private void CopyToolStripMenuItem_Click(object sender, EventArgs e)
        private void PasteToolStripMenuItem_Click(object sender, EventArgs e)
        private void ToolBarToolStripMenuItem_Click(object sender, EventArgs e)
            toolStrip.Visible = toolBarToolStripMenuItem.Checked;
        private void StatusBarToolStripMenuItem_Click(object sender, EventArgs e)
            statusStrip.Visible = statusBarToolStripMenuItem.Checked;
        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
            LayoutMdi(MdiLayout.Cascade);
        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
            LayoutMdi(MdiLayout.TileVertical);
        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
            LayoutMdi(MdiLayout.TileHorizontal);
        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
            LayoutMdi(MdiLayout.ArrangeIcons);
        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
            foreach (Form childForm in MdiChildren)
                childForm.Close();
// ===================================================================================
// ===================================================================================
    public partial class TestForm : Form
        private ReportDocument crDocument;
        public TestForm()
            InitializeComponent();
        private void TestForm_Load(object sender, EventArgs e)
            crDocument = new ReportDocument();
            crDocument.Load(@"C:\Reports\Sample1.rpt");
            this.crystalReportViewer1.ReportSource = crDocument;
//            this.crystalReportViewer1.ReportSource = @"C:\Reports\Sample1.rpt";
        private void TestForm_FormClosing(object sender, FormClosingEventArgs e)
            this.crDocument.Dispose();
// ===================================================================================

Hi Martyn,
I tested this and found after using this code to re-initialize the report viewer there we still 400 GDI objects not getting released. This may or may not be a CR issue. Still testing.
Try this also, I simply created a close button but you should be able to do this in your form close method also depending on how you do it:
        private void CloseReport_Click(object sender, EventArgs e)
            rptClientDoc.Close();
            crystalReportViewer1.Dispose();
            GC.Collect();
            this.crystalReportViewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
            InitializeComponent();
            crystalReportViewer1.ShowExportButton = true;
            crystalReportViewer1.EnableRefresh = true;
            crystalReportViewer1.Controls.Count.ToString();
            crystalReportViewer1.BackColor.IsNamedColor.ToString();
            crystalReportViewer1.EnableToolTips = true;
            crystalReportViewer1.Refresh();
The issue has now been tracked - Problem_Report:  ADAPT01301248
Thanks again
Don
Edited by: Don Williams on Sep 15, 2009 11:01 AM

Similar Messages

  • Alchemy does not release ByteArray objects

    I'm trying to use libjpeg encoder to encode bitmap to jpeg and notice, that original data never releases from memory. After some testing I found tha alchemy hold references to them. Is that a bug or am I doing something wrong?
    Here is my ActionScript code:
    protected function doSomethingButton_clickHandler(event:MouseEvent):void
         var data:ByteArray = new ByteArray();
         for (var i:int = 0; i < 1000; i++) {
              data.writeInt(Math.round(10000 * Math.random()));
         Demo.doSomething(data); // This is an alchemy class
    And here is my *.gg file:
    import flash.utils.ByteArray;
    public function doSomething(data:ByteArray):void
    The functiion does nothing! And profiler shows that all of this ByteArray objects stay in memory:

    I'd like to know if the AS3_Release(data) is a valid thing to do, or not.
    It's been a while, but the last time I profiled for a leak in alchemy, it appears that the passed-in parameters (to an API compiled with gluegen) are kept in alchemy in some sort of weak reference Dictionary.  These get cleaned up when alchemy decides to scan for cleanup - not when you want them gone.
    So, passing-in objects that hold lots of memory (like a byte array) is a bad thing.  I had thousands of Rectangle objects being held by alchemy (and they do not get cleaned by a manual garbage collect in the profiler), but sure enough, they eventually go away.
    I didn't think that the AS3_Release on input parameters was a valid thing to do, but perhaps it is, provided the object isn't referenced anywhere else in alchemy for other valid reasons?  I wouldn't want things to blow up.

  • Executable does not release serial port after being stopped

    Greetings:
    I have created an executable that communicates through a serial port.  However, if I stop the executable (not close it), the executable still has control over the COM port.  This causes issues if I need to jump on Hyperterminal to send a couple quick queries to my system.  In order to send the queries, I have to actually close the executable in order to release the COM port.  It's problematic because I then have to start the executable back up, go through another configuration query, etc. and there are parameters from the previous run I would prefer to not lose.
    Is there a way to force a LabView executable into releasing it's hold on a COM port after it's stopped, without closing the executable completely?  If it makes a difference, I'm using LV 7.1 on a WinXP machine.  Thanks for any help!

    Gumby_Dammit wrote:
    I changed the settings to have the stop button visible in the menu bar along with the start button.  This is because the user has to select their COM port before continuing.  
    Raven has already said it but I'll say it a different way.  No user should ever interact with the front panel unless the VI is running.  And when it is running the user should never have access to the abort button in the toolbar.  When you open Internet Explorer do you first need to click the run button?  No it runs when you run it.  Write your program so it is always running, and doesn't have an abort so if the user closes the program you can run the proper clean up like closing COM ports.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • JInternalFrame is closed, but does not release the memory

    Hi,
    I have problem with using of JInternalFrame.
    I create a new internal frame, and close it."setClosed(true);dispose();"
    The frame does not release the memory (after gc the allocated memory is the same)
    Before close I removed all listeners, and closed all reference to other object. (I think so :-) )
    Do You have any idees?
    regards
    G�bor

    Hi,
    I think u will have to release all the associated used objects. or you can also call the finalize() method in order to release the memory.
    Regards,
    Balaji.SN

  • Management Studio 2008 does not refresh after table create / alter

    hello
    Management Studio 2008 does not refresh after table create / alter, why?
    f5 / refresh button does not work in "Object Explorer".... i always need the restart the whole application to see any changes, this is strange...
    regards, jan

    Hi jm,
    I’m writing to follow up with you on this post. Was the problem resolved after performing Vishal ‘s steps? If you are satisfied with our solution, I’d like to mark this issue as "Answered". Please also feel free to unmark the issue, with any new findings
    or concerns you may have.
    Thanks,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Photoshop does not release memory after closing document.

    When I close a large document Photoshop does not release the memory. If I open another document the program is slow and not resposive. If I close out of Photoshop and restart it then load the other document it is quick and responsive again.

    A bit late to the party here but this issue is still live and I can't find anything else on the forum similar to it (apologies if there is).
    Photoshop does not seem to re-use memory it just keep allocating new right up to the limit before the prog crashes (same applies to Fireworks) so any batch/script processing of more than a handful of files is impossible.
    I am Photoshop via Creative Cloud (so I am always updated to your latest release), Windows 7 64k with 8Mb memory and am using Norton Intenet Security 20.3.1.22 which is updated daily.

  • ORB does not perform clean up after destroy() is called.

    hi,
    the HelloClient example (POA model) which is provided in the Java IDL tutorials, does not perform clean up after the execution is complete.
    i.e. i can still find the Socket descriptors in the file system under the path (/proc/p_id/fd). Do we need to explicitly destroy the sockets inorder to perform the required clean up??the OS i'm using is Linux.
    if yes, then how do i do that.... the following are the steps to reproduce the problem:
    1)start HelloServer
    2)start HelloClient
    3)check file count in /proc/process_id/fd before calling init.
    4)invoke ORB.destroy() method.
    5)check file count in /proc/process-id/fd after destroy completes.I have included Thread.sleep(25000) inorder to check the file count dynamically at each stage of execution.
    Any help in this regard is welcome....!!
    thanks in advance

    Hello:
    This reply may be long after the time that you need it ... but the problem
    that you are experiencing sounds very much like a bug that was fixed in the J2SE 1.5.0_10 release.
    It is bug 6354718 ....
    In the evaluation section of that bug they note:
    Yes. It's a known bug in ORB connection management. What's happening here is, the connectionCache that maintains both inbound and outbound connections does not reclaim connections, upon ORB destroy() call. There is a connection reclaim() logic in place, but does not kick in, until it reaches certain watermark levels. Since, a single client can have a multiple ORBs and thereby multiple outbound connections (in the reported case) , with each cache having exactly one connection which leaks up on ORB exit. This leak multiplies based on the number of ORBs and time period over which client stays live, up and running.
    The solution is, to walk through the connection cache and close each connection,
    no matter what the watermark levels are. This can be done at the corba transport manager close() call.
    Note: In the above evaluation they tell you how to fix it yourself but I believe (I haven't tested it yet ....) that if you upgrade to JDK 1.5.0_10, you should find that it has been fixed for you.
    I hope that I'm not steering you wrong, but that's my take on your situation.
    John

  • Discovery does not remove deleted objects

    Well,
    another issue with discoveries.
    We are running discoveries via datafile:
    The discovery DataSource script reads the datafile and creates the objects.
    That's very nice and works perfectly.
    Added entries in the datafile are discovered on the next discovery cycle.
    Unfortunately if you delete some entries from the datafile the discovery does not delete the objects in SCOM.
    Discovery's datasource writes a logfile and the deleted entries from the datafile are really no longer discovered
    ( I'm happy that reading files is a reliable function...).
    So for this cycle discovery data contains some objects less than before.
    But this new discovery does not lead to a deletion of no longer existing objects.
    As a workaround we put these superflues objects in maintenance mode.
    Would be gratefull if somebody has a good solution
    regards
    sebastian

    Please run "Remove-SCOMDisabledClassInstance” from the Operations Manager PowerShell
    console.
    You might get some errors after running this. Errors are about the ObjectIDs and RuleIDs, but you can ignore those errors and should keep running this command until it completes successfully.
    After completing successfully, the deleted objects will be removed the discovery and SCOM.
    Hope this helps.
    Thanks, S K Agrawal

  • I can't rate or write a review for app on the app store. It allows me to write out the review but does not diplay my review after sending it. Can anyone point me in the right direction to get answer as apply refuse to reply or solve my problem. Thanks

    I can't rate or write a review for app on the app store. It allows me to write out the review but does not diplay my review after sending it. Can anyone point me in the right direction to get answer as apply refuse to reply or solve my problem. Ps thanks apple for ur ignorance

    I have the same problem with another TeamLava app, Fashion Story.

  • IPod shuffle does not recognized by iTunes after restore

    Hello
    I have a iPod shuffle (4th gen) and a windows laptop.
    After restoring my iPod shuffle (as directed by iTunes), iTunes does not recognized my iPod anymore.
    The data in the iPod has been deleted (ie return to the factory settings), but iTunes does not proceed to prompt me to name my iPod and set up sync options etc, it simply does nothing and does not recognize my iPod. 
    I went on My Computer, and reformatted the iPod shuffle again. As a result of the reformatting, iTunes recognizes my iPod but it requires me to restore my iPod back to factory settings again. It became a cycle of either recognizing the iPod but asking me to restore it; or does not recognize my iPod after restoration.
    Please kindly assist me with this situation as it is rather frustrating.
    iTunes is in the latest version as I have attempted the trouble shooting support on the webpage.
    Many thanks.

    Hi priscillayeung,
    If you are having issues with your iPod being recognized by your Windows computer but not by iTunes (or being recognized but requiring a restore, which then causes it to not be recognized again), you may find the troubleshooting steps outlined in the following article helpful:
    iPod: Appears in Windows but not in iTunes
    http://support.apple.com/kb/TS1363
    Regards,
    - Brenden

  • Canon Pixma MP 540 does not scan any longer after update mountain lion. printer works normally. Who can help.

    My Canon Pixma MP 540 does not scan any longer after update mountain lion. MP Navigator EX 2.0 starts and immediatley stops and comes with this message:
    Application Specific Information:
    *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSImageCell loadingState]: unrecognized selector sent to instance 0x825c0f0'
    Printer works normally. Who can help.
    Thank you
    PeterPan52

    Hi
    Did you find a solution to this ? I amhaving same problem
    Thanks

  • My iPad does not automatically shut off after several minutes of non use. I can shut it off with the on/off switch. What can I do to get the auto sut off feature back?

    My IPad does not automatically shut off after several minutes of non use as it had been doing a few days ago  How can I restore this auto feature?

    Settings>General>Auto-Lock and select an Auto-Lock time (the "Never" setting will of course never auto-lock the device)

  • Scroll bar does not retain its position after or before pack

    Hi
    My Scroll bar does not retain its position after pack in my application.
    But i need to retain its state.
    My code snippet is :
    System.out.println("VAlue--->" + getHXValue());
    scrollPane.getHorizontalScrollBar().setValue(getHXValue());
    pack();
    My VAlue printed is 100.
    But my positon of scroll bar is at 0 th location.
    Can any one help me.....

    Swing related questions should be posted in the Swing forum.
    My code snippet is :Snippets don't help.
    If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)",
    see http://homepage1.nifty.com/algafield/sscce.html,
    that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
    Don't forget to use the "Code Formatting Tags",
    see http://forum.java.sun.com/help.jspa?sec=formatting,
    so the posted code retains its original formatting.

  • Photo library does not sync in iOS4 after upgrade in 3GS

    Hi all,
    Photo library does not sync in iOS4 after upgrade in 3GS.
    Anyone having such problems?

    Just did. Uncheck sync photo check box and sync. Then check sync photo check box and sync. Solved.

  • Error : software component version does not support this object type.

    Hi ,
    We are getting error as software component version does not support this object type when we try to create Business Object in PI 7.1 ESR  .
    How can we solve this error.
    Regards,
    Syed
    Edited by: Umar Syed on Jun 11, 2009 12:01 PM

    Hi Srinivas,
    We are working on Modelling in SAP PI, but we are unable to create any Business Object.. is there any specific steps need to be followed.
    Once we login to our ESR from index page we have this option to choose
    Available Profiles :         Process Definition
                                       Service Definition
                                       Unregistered.
    We are getting the option of new types (_Business Object_) only if we select Unregistered Profile and not in other Profiles . Is there some settings need to be done.
    Regards,
    Syed

Maybe you are looking for

  • How do I use my Email facility

    I am a new Blackberry user and being of advanced years find some of the new technology difficult to understand.  I have now posted 3 questions on this forum and have been delighted with the help I have received. My 4th question is as follows: I have

  • Problem in Translation Transport

    Hi, I have done the translation of the Text element using SE38. But my problem is that even i manually include the objects in the transport request. the translation is not reflecting in the target system. Thanks, Martin

  • Mac Mini Display

    I have a newer 20'' Memorex LCD TV. It can be used specifically for a monitor because there is a PC channel and it is also inteded in the manual. I just ordered my Min yesterday and ive been reading that there has been a few issues with LCD tv's and

  • Objective-c language6

    james-collinss-macbook-pro:prog9 jamescollins$ gcc Square.m Rectangle.m Point.m prog9.3.m -o prog9.3.m -l objc In file included from Square.h:1, from Square.m:1: Rectangle.h:13: error: syntax error before ‘{’ token In file included from Rectangle.m:1

  • Security Warning in Adobe Reader beim Öffnen eines pdf-Links

    Hallo zusammen Wir haben das folgende Problem: Wenn wir im Adobe Reader einen pdf-Link öffnen, erhalten wir jedesmal die Security Warnung, auch wenn wir dort angeben, dass die Werte für die nächsten male gespeichert werden sollen. Weiss jemand, wie m