Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

SignalGenerator crashes with OutOfMemoryException

Hi all

This simple Application crashes with :

'NationalTest.vshost.exe' (Managed): Loaded 'C:\Dokumente und Einstellungen\Kessler\Eigene Dateien\Visual Studio 2005\Projects\NationalTest\NationalTest\bin\Debug\NationalTest.exe', Symbols loaded.
'NationalTest.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\NationalInstruments.Analysis.Enterprise\8.0.20.334__4544464cdeaab541\NationalInstruments.Analysis.Enterprise.dll', No symbols loaded.
'NationalTest.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Exception of type 'System.OutOfMemoryException' was thrown.
A first chance exception of type 'System.OutOfMemoryException' occurred in NationalInstruments.Analysis.Enterprise.dll
The thread 0xd84 has exited with code 0 (0x0).

If i reduce the number of Points, it works fine. But we have to generate waves up to 1GB...

Any idee to resolve this problem ?

namespace NationalTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            try
            {
                SignalGenerator sigGen = new SignalGenerator(50, 50000000, 10);
                sigGen.Signals.Add(new SineSignal(1, 2, 0));
                double[ ] yData = sigGen.Generate();
            }
            catch( Exception ex )
            {
                System.Console.WriteLine(ex.Message);
            }
        }
    }
}
0 Kudos
Message 1 of 4
(4,033 Views)
Looks like your system ran out of memory. The .NET memory manager is throwing this error because it could not allocation that much memory for your process. This is not something our libraries have control over.

Do you need to allocate a gig of memory in one go? It would be better if you allocated it in chunks and saved it in a file instead of leaving it in memory.

Bilal Durrani
NI
0 Kudos
Message 2 of 4
(4,028 Views)

hi

 

  double[] roundWaveform = new double[4194304];

NationalInstruments.ComplexDouble[] complexData = NationalInstruments.Analysis.Dsp.Transforms.RealFft(roundWaveform);

System.OutOfMemoryException:

 
Out of memory error sometimes, but my Windows7 system also has a lot of memory, 4G of memory
Why?
0 Kudos
Message 3 of 4
(3,363 Views)

It has nothing to do with the amount of RAM you have. Windows can give some place from pagefile if it lacks RAM. But, you should read about .NET memory constrains per process and per object. For example it is worth to notice that in Windows 7 32 bit .NET process cannot allocate more then 2GB, and on any version of Windows .NET object cannot allocate more than 2GB.

Just use Google to read about those topics 🙂

0 Kudos
Message 4 of 4
(3,345 Views)