Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
GeneralRe: Analogclock and timer Pin
Aljaz11112-May-09 12:07
Aljaz11112-May-09 12:07 
AnswerRe: Analogclock and timer Pin
Aljaz11112-May-09 12:44
Aljaz11112-May-09 12:44 
QuestionImages in Gridview Pin
stewy0912-May-09 6:11
stewy0912-May-09 6:11 
AnswerRe: Images in Gridview Pin
Henry Minute12-May-09 7:18
Henry Minute12-May-09 7:18 
Questionrunning out of memory, issues with GC Pin
Jon Hulatt12-May-09 5:46
Jon Hulatt12-May-09 5:46 
AnswerRe: running out of memory, issues with GC Pin
Luc Pattyn12-May-09 6:51
sitebuilderLuc Pattyn12-May-09 6:51 
GeneralRe: running out of memory, issues with GC Pin
Jon Hulatt12-May-09 8:06
Jon Hulatt12-May-09 8:06 
GeneralRe: running out of memory, issues with GC Pin
Luc Pattyn12-May-09 9:19
sitebuilderLuc Pattyn12-May-09 9:19 
Hi Jon,

I think I start to get the overall picture now.

Here are some thoughts:

1. your buffers are "large", i.e. larger than 85KB, hence allocated on the large-object-heap LOH which never gets compacted, and therefore is subject to fragmentation (unless all objects have the exact same size). In extreme cases fragmentation could mean your app is really using only a few megabytes, yet fails to allocate one more megabyte.
Remember: collections such as lists are implemented as arrays, not linked lists, so whenever their count exceeds the next power of two, the array gets reallocated with twice the size, potentially also invading the LOH.

2.
The line jpegData = nullptr; probably is not relevant since in the previous line (m_callback->ReturnFrame(jpegData);) you passed the reference to another method, which could store it somehow, and hence keep the array alive.

3.
You may have a performance problem: with 5 frames per second, you need an overall throughput of 23MB/sec which you copy once with Marshal.Copy, copy once more with m_outputWriter.Write, and finally the system must dump to the disk in order for the memory to become available again. That could be beyond your system's capabilities; watch Task Manager and/or experiment with less data (smaller frames, or fewer frames per second, maybe skip every second frame).

4.
Maybe you could simplify things (and reduce the system load) by passing a ready-made buffer to your native code, rather than have it allocate, fill, copy and deallocate. That is how I have always done image processing in mixed environments.
If all the data needs to go through is generate natively and write to a managed file, you could do that with just one array, using it over and over.

Hope this helps. If you need more detailed discussions, I'd probably want to see ALL code relevant to allocating, pinning. copying and freeing buffers.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.

QuestionWorking with multiple forms Pin
bwood202012-May-09 5:34
bwood202012-May-09 5:34 
AnswerRe: Working with multiple forms Pin
OriginalGriff12-May-09 5:37
mveOriginalGriff12-May-09 5:37 
GeneralRe: Working with multiple forms Pin
bwood202012-May-09 5:56
bwood202012-May-09 5:56 
AnswerRe: Working with multiple forms Pin
DaveyM6912-May-09 5:49
professionalDaveyM6912-May-09 5:49 
GeneralRe: Working with multiple forms Pin
bwood202012-May-09 6:03
bwood202012-May-09 6:03 
GeneralRe: Working with multiple forms Pin
DaveyM6912-May-09 6:20
professionalDaveyM6912-May-09 6:20 
GeneralRe: Working with multiple forms Pin
bwood202012-May-09 7:17
bwood202012-May-09 7:17 
GeneralRe: Working with multiple forms Pin
Henry Minute12-May-09 7:28
Henry Minute12-May-09 7:28 
GeneralRe: Working with multiple forms Pin
bwood202012-May-09 9:13
bwood202012-May-09 9:13 
GeneralRe: Working with multiple forms Pin
Henry Minute12-May-09 9:22
Henry Minute12-May-09 9:22 
GeneralRe: Working with multiple forms Pin
bwood202012-May-09 9:48
bwood202012-May-09 9:48 
GeneralRe: Working with multiple forms Pin
Henry Minute12-May-09 10:00
Henry Minute12-May-09 10:00 
GeneralRe: Working with multiple forms Pin
bwood202012-May-09 11:10
bwood202012-May-09 11:10 
GeneralRe: Working with multiple forms Pin
Henry Minute12-May-09 11:54
Henry Minute12-May-09 11:54 
GeneralRe: Working with multiple forms Pin
bwood202013-May-09 4:02
bwood202013-May-09 4:02 
GeneralRe: Working with multiple forms Pin
bwood202013-May-09 6:20
bwood202013-May-09 6:20 
GeneralRe: Working with multiple forms Pin
Henry Minute13-May-09 6:38
Henry Minute13-May-09 6:38 

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.