-->
Page 1 of 1

RAM - Losing too quickly

PostPosted: Mon Dec 08, 2014 10:52 am
by scargill
Hi

The HEAP issue is coming up again... making little toy projects you don't have a problem..

Here's where I'm up to.

I have a FILE I can call which:

Creates a timer function which depending on a counter will: initialise the connection to the router, start reading the Dallas chips (once every 20 seconds - and I've split the function to eliminate the delay) - then setup a TCP/IP listener to respond to remote controls to turn an output on and off.

If I set up a couple of variables and DOFILE this- it works reliably.

If I put the variables into the init.lua and call the DOFILE - the board goes into a loop
If I put the variables into the init.lua and start off a one-off timer and have THAT call DOFILE - the board goes into a loop.

If I do it manually and then STOP the timer that is overseeing all of this.... I find I have something like 5k of RAM left - from experience I know that it takes VERY LITTLE to crash the board with that amount of RAM.

Can you further speed up the HEAP recovery and is there anything else you can do to retrieve RAM?


Pete.

Re: RAM - Losing too quickly

PostPosted: Tue Dec 09, 2014 5:05 am
by ThomasW
Hi Pete,

Hard to tell without seeing the code but I guess you're having issues with the scope of your variables - dofile() always executes in the global context and won't see local variables when called from within a function.
Regarding the memory usage - 5k left for a listener and a transmit function seems to be very little - is there much code inside these functions? Extensive use of globals can also be an issue - they won't "go away" unless explicitly set to nil.

Thomas