Click here to Skip to main content
15,913,941 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Out of memory exception - graphics Pin
Luc Pattyn22-Sep-09 7:35
sitebuilderLuc Pattyn22-Sep-09 7:35 
GeneralRe: Out of memory exception - graphics Pin
TheComputerMan22-Sep-09 10:42
TheComputerMan22-Sep-09 10:42 
GeneralRe: Out of memory exception - graphics Pin
Luc Pattyn22-Sep-09 11:47
sitebuilderLuc Pattyn22-Sep-09 11:47 
GeneralRe: Out of memory exception - graphics Pin
TheComputerMan22-Sep-09 12:03
TheComputerMan22-Sep-09 12:03 
GeneralRe: Out of memory exception - graphics Pin
TheComputerMan22-Sep-09 12:06
TheComputerMan22-Sep-09 12:06 
GeneralRe: Out of memory exception - graphics Pin
TheComputerMan22-Sep-09 12:36
TheComputerMan22-Sep-09 12:36 
GeneralRe: Out of memory exception - graphics Pin
Luc Pattyn22-Sep-09 12:50
sitebuilderLuc Pattyn22-Sep-09 12:50 
GeneralRe: Out of memory exception - graphics Pin
Ian Shlasko22-Sep-09 7:58
Ian Shlasko22-Sep-09 7:58 
Though I agree Luc could have been a little nicer, he's right on all four points.

1) If you know what the exception is, and are intentionally ignoring it (Not ideal, but sometimes unavoidable), you should at least catch the specific exception being triggered... For example, "Catch ex as FileNotFoundException", so you won't miss an unexpected one.

2) As he said, sleeping the thread won't help, but you realized that.

3) Yes, setting a local variable to nothing is meaningless, since it will go out of scope as soon as the method ends. This was needed back in VB6 when you didn't have a Dispose() method, but no longer.

4) Definitely put all disposes in Finally blocks, otherwise they'll be skipped if an exception occurs. If you want to keep things simple, define both disposables at the beginning of the method (Initialized to null), and only try to dispose if they're non-null. That way you don't need an extra try loop just for the graphics object.

Other suggestions:

5) Don't use "new IntPtr()"... Use IntPtr.Zero

6) From the MSDN article for GetThumbnailImage, in reference to the callback parameter: "In GDI+ version 1.0, the delegate is not used. Even so, you must create a delegate and pass a reference to that delegate in this parameter"... As we don't know how this is implemented (By Microsoft), this may or may not be the cause.

If none of these solve your problem, it may be elsewhere in your program... Just because this method does the heavy lifting, doesn't necessarily mean it's the only one that can leak.

Proud to have finally moved to the A-Ark. Which one are you in?
Developer, Author (Guardians of Xen)

GeneralRe: Out of memory exception - graphics Pin
TheComputerMan22-Sep-09 11:04
TheComputerMan22-Sep-09 11:04 
GeneralRe: Out of memory exception - graphics Pin
Ian Shlasko22-Sep-09 11:13
Ian Shlasko22-Sep-09 11:13 
GeneralRe: Out of memory exception - graphics Pin
TheComputerMan22-Sep-09 11:50
TheComputerMan22-Sep-09 11:50 
GeneralRe: Out of memory exception - graphics Pin
TheComputerMan22-Sep-09 12:00
TheComputerMan22-Sep-09 12:00 
GeneralRe: Out of memory exception - graphics Pin
Luc Pattyn22-Sep-09 12:37
sitebuilderLuc Pattyn22-Sep-09 12:37 
GeneralRe: Out of memory exception - graphics Pin
TheComputerMan22-Sep-09 12:39
TheComputerMan22-Sep-09 12:39 
GeneralRe: Out of memory exception - graphics Pin
TheComputerMan22-Sep-09 12:37
TheComputerMan22-Sep-09 12:37 
GeneralRe: Out of memory exception - graphics Pin
Dave Kreskowiak22-Sep-09 9:13
mveDave Kreskowiak22-Sep-09 9:13 
QuestionHow to track all events/function calls fired in vb6 and log it Pin
CPK_201122-Sep-09 3:34
CPK_201122-Sep-09 3:34 
AnswerRe: How to track all events/function calls fired in vb6 and log it Pin
Dave Kreskowiak22-Sep-09 4:31
mveDave Kreskowiak22-Sep-09 4:31 
GeneralRe: How to track all events/function calls fired in vb6 and log it Pin
CPK_201122-Sep-09 4:35
CPK_201122-Sep-09 4:35 
GeneralRe: How to track all events/function calls fired in vb6 and log it Pin
Dave Kreskowiak22-Sep-09 4:44
mveDave Kreskowiak22-Sep-09 4:44 
GeneralRe: How to track all events/function calls fired in vb6 and log it Pin
CPK_201122-Sep-09 4:59
CPK_201122-Sep-09 4:59 
GeneralRe: How to track all events/function calls fired in vb6 and log it Pin
Dave Kreskowiak22-Sep-09 5:13
mveDave Kreskowiak22-Sep-09 5:13 
QuestionVB.NET: Error adding multiple rows in a DataGridView (not bound to a DataTable) Pin
Dimitri Backaert22-Sep-09 2:33
Dimitri Backaert22-Sep-09 2:33 
AnswerRe: VB.NET: Error adding multiple rows in a DataGridView (not bound to a DataTable) Pin
Jay Royall22-Sep-09 2:52
Jay Royall22-Sep-09 2:52 
GeneralRe: VB.NET: Error adding multiple rows in a DataGridView (not bound to a DataTable) Pin
Dimitri Backaert22-Sep-09 2:59
Dimitri Backaert22-Sep-09 2:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.