Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 13:13 07 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM Insufficient memory

Author Message
Chrisk

Senior Member

Joined: 21/12/2014
Location: Australia
Posts: 122
Posted: 07:11pm 09 Jul 2016
Copy link to clipboard 
Print this post

Hi all
Again I need your help.
I am using a CMM with MMBasic 4.5
I have been adding quite a few variables to the point that I now get an error message - Error: Not enough memory

The line at which the error occurs is shown below. It's not the line, as it worked before I added the additional variables
When I remove the variables it works.
[279] Print #1,Date$,Mid$(Time$,1,5),Format$(ATT1,"%4.1f"),Format$(ATT2,"%4.1f"),Format$(ATT1-ATT2,"%4.1f"),Format$(RHM,"%4.1f");
Error: Not enough memory

At another time:
[435] LCD 1, 1, "T" + Format$(LT1,"%02g") + " B" + Format$(LT2,"%02g") + " A"+ Format$(LTA,"%02g") + " " + Format$(Mnt,"%02g") + Format$(Mxt,"%02g")' Display Top, Bottom and Average Temps
Error: Not enough memory

The memory command shows the following

> memory
20kB (59%) Program (604 lines)
8kB (25%) 60 Variables
1kB ( 3%) General
5kB (13%) Free

I appears that these variables and their use of memory are the problem.
Any suggestions how I can work around the problem?

ChrisK
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 07:38pm 09 Jul 2016
Copy link to clipboard 
Print this post

Assuming that the problem is the line getting too complex, break it down to bite sized pieces.

temp$ = DATE$+MID$(TIME$,1,5)+FORMAT$(ATT1,"%4.1f")+FORMAT$(ATT2,"%4.1f")
temp$ = temp$ +FORMAT$(ATT1-ATT2,"%4.1f")+FORMAT$(RHM,"%4.1f")
PRINT #1, temp$;


temp$ = "T" + FORMAT$(LT1,"%02g") + " B" + FORMAT$(LT2,"%02g")
temp$ = temp$ + " A"+ FORMAT$(LTA,"%02g") + " " + FORMAT$(Mnt,"%02g") + FORMAT$(Mxt,"%02g")
LCD 1, 1, temp$


For a true 'out of memory' problem,
start by striping the comments from your code before loading.

Jim
VK7JH
MMedit
 
Chrisk

Senior Member

Joined: 21/12/2014
Location: Australia
Posts: 122
Posted: 09:54pm 09 Jul 2016
Copy link to clipboard 
Print this post

Hi TassyJim

I had searched the forum about 'out of memory' and the shortening was suggested.
I tried that but made no difference. I then resorted to TBS.

I stripped all the comments out as you suggested and reduced the file by 25% and it worked but this will make the debugging difficult in the future.
Is there any way of keeping the comments but doing something with the variables or something else?


ChrisK
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 10:06pm 09 Jul 2016
Copy link to clipboard 
Print this post

You can use MMEdit.
It has the option of stripping comments every time you upload and keeping line numbers aligned.

Apart from that, reusing variables can help

Jim

VK7JH
MMedit
 
skylight
Newbie

Joined: 10/01/2016
Location: United Kingdom
Posts: 23
Posted: 09:53am 10 Jul 2016
Copy link to clipboard 
Print this post

I had a problem with out of memory on another project using the same kit as the author of the software was using with no problems, I managed to get it working by changing the mode, The author was using mode 3 I changed to mode 2 and it worked. It was just strange that it worked fine for him even though we were using identical kit.
So perhaps this might help?Edited by skylight 2016-07-11
 
Chrisk

Senior Member

Joined: 21/12/2014
Location: Australia
Posts: 122
Posted: 12:57am 11 Jul 2016
Copy link to clipboard 
Print this post

I found TassyJim's suggestion great.

The stripped file was half the size.
I now keep a copy of both the commented and stripped files.
I differentiate by adding nc(no comments) to the filename.
Thanks again for your support.

ChrisK

 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025