Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Memory Exception while saving an image

Memory Exception while saving an image

Scheduled Pinned Locked Moved C#
graphicshelpcsharpwinformsalgorithms
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DeepOceans
    wrote on last edited by
    #1

    Hello I am working in C# and developing a desktop application. The main tasks of my application are Live Video Capturing, recording, transmission over LAN and motion detection. All are doing fine. But sometimes while grabbing a frame; it throws memory exception i-e "Attempted to read or write protected memory. This is often an indication that other memory is corrupt" at line b.Save("C:\\abc.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);// b is a bitmap object ///// other code b.dispose(); and after that it throws exception i-e "A generic error occurred in GDI+". As I m continuously grabbing frames in a loop. So once it throws an exception, it stops working. I m searching over it but still didn't get any solution. plz help me out thx

    Shanzay

    A 1 Reply Last reply
    0
    • D DeepOceans

      Hello I am working in C# and developing a desktop application. The main tasks of my application are Live Video Capturing, recording, transmission over LAN and motion detection. All are doing fine. But sometimes while grabbing a frame; it throws memory exception i-e "Attempted to read or write protected memory. This is often an indication that other memory is corrupt" at line b.Save("C:\\abc.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);// b is a bitmap object ///// other code b.dispose(); and after that it throws exception i-e "A generic error occurred in GDI+". As I m continuously grabbing frames in a loop. So once it throws an exception, it stops working. I m searching over it but still didn't get any solution. plz help me out thx

      Shanzay

      A Offline
      A Offline
      Alan Balkany
      wrote on last edited by
      #2

      Does your code interact with other non-managed code? I've seen this when using a C++ DLL from C#. When the error occurs, what field values does the debugger show in the bitmap object? If they're all the same weird byte value, it may mean that object was already Disposed by another part of the code. If this is happening, you need to trace backwards to locate where it occurs.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups