topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Monday March 18, 2024, 9:55 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: C# GDI+ Problem with byte[] and Bitmap - Memory Issues  (Read 32083 times)

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • View Profile
    • Donate to Member
Re: C# GDI+ Problem with byte[] and Bitmap - Memory Issues
« Reply #25 on: January 21, 2011, 10:59 AM »
Objects get GC'ed "at some point after there's no longer any references to them", which could mean aeons after they "go out of scope"... but it can even happen within the method where the variable referencing the object was initially allocated.

True.  Remember, too, though, that there is such as thing as memory pressure, which refers to the fact that the more objects there are in memory, the more often garbage collection occurs.  Not sure how much more often.

worstje

  • Honorary Member
  • Joined in 2009
  • **
  • Posts: 588
  • The Gent with the White Hat
    • View Profile
    • Donate to Member
Re: C# GDI+ Problem with byte[] and Bitmap - Memory Issues
« Reply #26 on: January 21, 2011, 11:01 AM »
My current pains actually involve BitmapFrame classes, so unless that isn't used by WinForms either, you might be up for some pain yet. It is a tried and true disaster, yessir. :( For now, I'd be happy enough to be rid of the crashes.

Edit:

Does the Bitmap.FromFile() call (or whatever) happen to use the System.Windows.Media.Imaging namespace? I think that one is WPF specific, but if it does there might be a solution in there. (I've been hating that one more than plenty so far.)
« Last Edit: January 21, 2011, 11:05 AM by worstje »

Renegade

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 13,288
  • Tell me something you don't know...
    • View Profile
    • Renegade Minds
    • Donate to Member
Re: C# GDI+ Problem with byte[] and Bitmap - Memory Issues
« Reply #27 on: January 21, 2011, 04:15 PM »
Objects get GC'ed "at some point after there's no longer any references to them", which could mean aeons after they "go out of scope"... but it can even happen within the method where the variable referencing the object was initially allocated.

True.  Remember, too, though, that there is such as thing as memory pressure, which refers to the fact that the more objects there are in memory, the more often garbage collection occurs.  Not sure how much more often.


I tried adding memory pressure, but it didn't help with the error. It's really just for when you use unmanaged memory.


My current pains actually involve BitmapFrame classes, so unless that isn't used by WinForms either, you might be up for some pain yet. It is a tried and true disaster, yessir. :( For now, I'd be happy enough to be rid of the crashes.

Edit:

Does the Bitmap.FromFile() call (or whatever) happen to use the System.Windows.Media.Imaging namespace? I think that one is WPF specific, but if it does there might be a solution in there. (I've been hating that one more than plenty so far.)



I don't believe so.

What I'd really like is to find an imaging library that doesn't suffer from these problems... Sigh...
Slow Down Music - Where I commit thought crimes...

Freedom is the right to be wrong, not the right to do wrong. - John Diefenbaker