Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

event handling issue.


  • Please log in to reply
4 replies to this topic

#1 gouaches

gouaches

    Member

  • Members
  • PipPip
  • 11 posts

Posted 03 February 2012 - 10:04 PM

Hi All,

I am trying to handle the button pressure.

I want to log the time when i press the button on Netduino plus but C# reports the following output message after i launch the app.


#### Exception System.OutOfMemoryException - CLR_E_OUT_OF_MEMORY (1) ####
#### Message:
#### System.Delegate::Combine [IP: 0000] ####
#### Microsoft.SPOT.Hardware.NativeEventDispatcher::add_OnInterrupt [IP: 0014] ####
#### NetduinoPlusApplication1.Program::Main [IP: 004a] ####
Uncaught exception

the code of my application is the following:


using System;
using System.Net;
using System.IO;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;

namespace NetduinoPlusApplication1
{
    public class Program
    {
     
        public static void Main()
        {
            DirectoryInfo usd = new DirectoryInfo(@"\SD\");
            InterruptPort button = new InterruptPort(Pins.GPIO_PIN_D8, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLevelLow);

            if (usd.Exists)
            { 
                usd.Create();
                usd.CreateSubdirectory(@"\SD\Prova\");
                FileStream fstr = new FileStream(@"\SD\Prova\prova.dat", FileMode.Create);
                fstr.Flush();
                fstr.Close();
               while (true)
               {
                   button.OnInterrupt += new NativeEventHandler(button_OnInterrupt);
                   button.ClearInterrupt();
              } //close while
            }//close if
        } //close Main

        static void button_OnInterrupt(uint port, uint state, DateTime time)
        {
            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
            int ltime = 50000; 
            StreamWriter fstr1 = new StreamWriter(@"\SD\Prova\prova.dat", true); 
            if (state == 0) {
                fstr1.WriteLine(System.DateTime.Now.ToString());
                fstr1.Flush();
                fstr1.Close();
                led.Write(true);
                Thread.Sleep(ltime);
                led.Write(false);
                //Thread.Sleep(ltime);
            };
        }

    }
}


Could someone explain me something about the exception not handled and what generate the exception?

Thank you!

Rgds, Daniele.

#2 gouaches

gouaches

    Member

  • Members
  • PipPip
  • 11 posts

Posted 03 February 2012 - 10:15 PM

here you can find a part of output window after i used Debug Message enabled: GC: 2msec 27408 bytes used, 23568 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 23568 bytes Type 16 (CACHEDBLOCK ): 264 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 1080 bytes Type 1C (DELEGATELIST_HEAD ): 684 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 408 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 28104 bytes used, 22872 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 22872 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 1908 bytes Type 1C (DELEGATELIST_HEAD ): 612 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 612 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 28680 bytes used, 22296 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 22296 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 2340 bytes Type 1C (DELEGATELIST_HEAD ): 756 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 612 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 29112 bytes used, 21864 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 21864 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 2664 bytes Type 1C (DELEGATELIST_HEAD ): 864 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 612 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 29400 bytes used, 21576 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 21576 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 2880 bytes Type 1C (DELEGATELIST_HEAD ): 936 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 612 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 29592 bytes used, 21384 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 21384 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 3024 bytes Type 1C (DELEGATELIST_HEAD ): 984 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 612 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 29784 bytes used, 21192 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 21192 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 3168 bytes Type 1C (DELEGATELIST_HEAD ): 1032 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 612 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 29928 bytes used, 21048 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 21048 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 3276 bytes Type 1C (DELEGATELIST_HEAD ): 1068 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 612 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 30120 bytes used, 20856 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 20856 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 3420 bytes Type 1C (DELEGATELIST_HEAD ): 1116 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 612 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 30264 bytes used, 20712 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 20712 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 3528 bytes Type 1C (DELEGATELIST_HEAD ): 1152 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 612 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 30408 bytes used, 20568 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 20568 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 3636 bytes Type 1C (DELEGATELIST_HEAD ): 1188 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 612 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 30504 bytes used, 20472 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 20472 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 3708 bytes Type 1C (DELEGATELIST_HEAD ): 1212 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 612 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 30648 bytes used, 20328 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 20328 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 3816 bytes Type 1C (DELEGATELIST_HEAD ): 1248 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 612 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 30696 bytes used, 20280 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 20280 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 3852 bytes Type 1C (DELEGATELIST_HEAD ): 1260 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 612 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 30792 bytes used, 20184 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 20184 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 3924 bytes Type 1C (DELEGATELIST_HEAD ): 1284 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 612 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 30840 bytes used, 20136 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 20136 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 3960 bytes Type 1C (DELEGATELIST_HEAD ): 1296 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 612 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 30936 bytes used, 20040 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 20040 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 4032 bytes Type 1C (DELEGATELIST_HEAD ): 1320 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 612 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 30984 bytes used, 19992 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 19992 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 4068 bytes Type 1C (DELEGATELIST_HEAD ): 1332 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 612 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 31080 bytes used, 19896 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 19896 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 4140 bytes Type 1C (DELEGATELIST_HEAD ): 1356 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 612 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 31128 bytes used, 19848 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 19848 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 4176 bytes Type 1C (DELEGATELIST_HEAD ): 1368 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 612 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 31224 bytes used, 19752 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 19752 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 4248 bytes Type 1C (DELEGATELIST_HEAD ): 1392 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes Type 20 (SUBTHREAD ): 144 bytes Type 21 (STACK_FRAME ): 612 bytes Type 23 (LOCK_HEAD ): 60 bytes Type 24 (LOCK_OWNER_HEAD ): 24 bytes Type 27 (FINALIZER_HEAD ): 48 bytes Type 31 (IO_PORT ): 72 bytes Type 34 (APPDOMAIN_HEAD ): 72 bytes Type 36 (APPDOMAIN_ASSEMBLY ): 1080 bytes GC: 2msec 31272 bytes used, 19704 bytes available Type 0F (STRING ): 204 bytes Type 11 (CLASS ): 1128 bytes Type 12 (VALUETYPE ): 48 bytes Type 13 (SZARRAY ): 552 bytes Type 15 (FREEBLOCK ): 19704 bytes Type 17 (ASSEMBLY ): 13284 bytes Type 18 (WEAKCLASS ): 48 bytes Type 1B (DELEGATE_HEAD ): 4284 bytes Type 1C (DELEGATELIST_HEAD ): 1404 bytes Type 1D (OBJECT_TO_EVENT ): 48 bytes Type 1E (BINARY_BLOB_HEAD ): 7008 bytes Type 1F (THREAD ): 1152 bytes But now i have problems for understand the meaning of data and eventually discover where is the error. Best wishes!

#3 ErikN

ErikN

    Advanced Member

  • Members
  • PipPipPip
  • 119 posts
  • LocationNew York, NY

Posted 03 February 2012 - 10:39 PM

Everything you need to know was right there in the first error:

#### Exception System.OutOfMemoryException - CLR_E_OUT_OF_MEMORY (1) ####
#### Message:
#### System.Delegate::Combine [IP: 0000] ####
#### Microsoft.SPOT.Hardware.NativeEventDispatcher::add_OnInterrupt [IP: 0014] ####
#### NetduinoPlusApplication1.Program::Main [IP: 004a] ####



This is saying in your application NetduinoPlusApplication1 has an object Program with a function Main which has some instruction that is, under the hood, calling NativeEventDispatcher object's add_OnInterrupt method. That is in turn calling Delegate object's Combine method. From experience, I know when you do <event> += <handler> this uses Combine to join your new handler into the pool of handlers that want to be called when this event is fired.

That gives us all the information we need to find the problem. Looking at your code, there's only one place you're doing a handler assignment to an event:
while (true)
{
    button.OnInterrupt += new NativeEventHandler(button_OnInterrupt);
    button.ClearInterrupt();
}

We see this is being done in an infinite loop. Basically you're attaching a copy of your event handler again and again and again until the Netduino runs out of memory space.

You can read up on Event Based Programming but in short to fix your issue, just move your event wire-up above the while loop (which I assume you have just to keep the main thread alive; in which case you should consider adding a sleep call to put the main thread to sleep when it's not needed.)

Hope this helps!

-Erik

#4 gouaches

gouaches

    Member

  • Members
  • PipPip
  • 11 posts

Posted 07 February 2012 - 05:57 PM

Hi Erik, First of all i want to say thank you for your help. Then i have a question: How can i do a infinite-loop using Thread.sleep method? It request a finite-time has parameter. thank you very much. Best Regards, Daniele.

#5 ErikN

ErikN

    Advanced Member

  • Members
  • PipPipPip
  • 119 posts
  • LocationNew York, NY

Posted 07 February 2012 - 06:03 PM

It depends on your need. If you want to wake up from time to time before going back to sleep:



public static void Main()
{
    //Do your event wireup and any other thread work

    //Then, last thing:
    while(true)
    {
        //Do any periodic work you need executed on the main thread for some reason
        Thread.Sleep(10000); // 10 seconds or whatever
    }
}


If you don't ever need the main thread to wake up to do something then you don't need a loop at all and you can put the thread to sleep forever. Your event threads will continue to process; this is just the main thread which you need to keep active so the whole program doesn't terminate.



public static void Main()
{
    //Do your event wireup and any other thread work

    //Then, last thing:
    Thread.Sleep(Timeout.Infinite);
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.