c# - How to reduce memory usage for processing many images? -


i working on c# wpf application uses pixel data many images process 1 image.

  1. it requires user open multiple images of format.
  2. these images stored using system.drawing.bitmap class in memory using lockbits() method , memory addresses first pixel datas stored in byte*.
  3. new system.drawing.bitmap created , processed using lockbits() method , direct memory access in unsafe context system.threading.tasks.parallel class, , pixel values calculated using pixel values of opened images each pixel , saved memory.
  4. processed system.drawing.bitmap encoded jpeg , saved selected location.
  5. dispose(), unlockbits() , gc.collect() methods called.

the problem above method, opened images must stay in memory until whole operation completed.
example, if open 50 images resolution of 4160x3120, takes 4160*3120*3*50 bytes: 1857 megabytes of memory.

is there possible solution not require images in memory, or other solution reduce memory usage?

i working on c# wpf application uses pixel data many images process 1 image.

if need pixel data many images need them in memory. can't process pixels directly or disk. approach should minimize images required.

if pixel processing same relative location maybe break image sections (e.g. quarters).


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -