Toot
August 29th, 2006, 06:44 AM
My C# client is passing a large array into my managed C++ class like this:
bool JEMFFT::ConfigureInputs(__int16 Samples __gc[], ...)
My managed class is going to need to take a copy of this array as it's going to start a worker thread & pass it down into some pre-written C functions to do the work. I do a small amount of setting up then call:
m_uiNumSamples = Samples->Count;
if (m_uiNumSamples > 0)
m_pSamples = __nogc new __int16[m_uiNumSamples];
or
m_uiNumSamples = Samples->Count;
if (m_uiNumSamples > 0)
m_pSamples = (__int16*)malloc(m_uiNumSamples * sizeof(__int16));
Both of these throw a System.StackOverflowException. Any ideas why? Firstly, why a stack overflow as I'm trying to use the heap? Secondly, why? In the test case I'm playing with now, the number of items in the Samples array is 307,200 but I've tried hard-coding the m_uiNumSamples value to 2 and I still get the exception. It's as though I'm not allowed to allocate heap memory for some reason. I've spent many frustrating hours trying to work out & scanning forums but can't for the life of me work it out. I'm clearly missing something dumb ... any clues anyone?
Thanks very much for your advice,
T
bool JEMFFT::ConfigureInputs(__int16 Samples __gc[], ...)
My managed class is going to need to take a copy of this array as it's going to start a worker thread & pass it down into some pre-written C functions to do the work. I do a small amount of setting up then call:
m_uiNumSamples = Samples->Count;
if (m_uiNumSamples > 0)
m_pSamples = __nogc new __int16[m_uiNumSamples];
or
m_uiNumSamples = Samples->Count;
if (m_uiNumSamples > 0)
m_pSamples = (__int16*)malloc(m_uiNumSamples * sizeof(__int16));
Both of these throw a System.StackOverflowException. Any ideas why? Firstly, why a stack overflow as I'm trying to use the heap? Secondly, why? In the test case I'm playing with now, the number of items in the Samples array is 307,200 but I've tried hard-coding the m_uiNumSamples value to 2 and I still get the exception. It's as though I'm not allowed to allocate heap memory for some reason. I've spent many frustrating hours trying to work out & scanning forums but can't for the life of me work it out. I'm clearly missing something dumb ... any clues anyone?
Thanks very much for your advice,
T