DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

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

kyrathaba

  • N.A.N.Y. Organizer
  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 3,200
    • Participated in NANY Challenge Eight Times
    • Programming School - Deluxe Bonus Medal
    • Programming School - Stage 1 Medal
    • Coding Snacks
    • Military Service Badge - US Army
    • Writer
Re: C# GDI+ Problem with byte[] and Bitmap - Memory Issues
« Reply #25 on: January 21, 2011, 04:59 PM »
Quote
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.
Win 10 Pro running on a 3.2 GHz CPU and 12 Gb RAM
__________________________________________

Proofreading Service: http://williammillerservices.com/proofreading

worstje

  • The Gent with the White Hat
  • Honorary Member
  • Joined in 2009
  • **
  • Posts: 589
    • Coding Snacks
    • Participated in NANY Challenge Three Times
Re: C# GDI+ Problem with byte[] and Bitmap - Memory Issues
« Reply #26 on: January 21, 2011, 05:01 PM »
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, 05:05 PM by worstje »

Renegade

  • Tell me something you don't know...
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 13,291
    • Participated in NANY Challenge Three Times
    • Furry Fandom Badge - Furry Fandom
    • Linux User
Re: C# GDI+ Problem with byte[] and Bitmap - Memory Issues
« Reply #27 on: January 21, 2011, 10:15 PM »
Quote
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

Original address: https://www.donationcoder.com/forum/index.php?topic=25345.0