| Author |
Message |
carlm Newbie
 Joined: 31/05/2018 Location: AustraliaPosts: 10 |
| Posted: 11:15pm 20 Jun 2018 |
Copy link to clipboard |
 Print this post |
|
Hi, I have been putting some code for a project together for a Micromite LCD Backpack. All was going well until I get the following message on a load and run
[55] Const DecWarning10 = 25 Error: Not Enough memory
There is nothing special about line 55 in my code. I have cut my program right back until there is virtually nothing in it besides these declarations but the error does not seem to disappear.
I assume that this is something basic. Can anyone help?
Thanks in Advance. |
| |
panky
 Guru
 Joined: 02/10/2012 Location: AustraliaPosts: 1116 |
| Posted: 11:33pm 20 Jun 2018 |
Copy link to clipboard |
 Print this post |
|
@carlm
Can you type in the MEMORY command at the prompt and report back on what it says?
panky
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |
| |
Azure
 Guru
 Joined: 09/11/2017 Location: AustraliaPosts: 446 |
| Posted: 11:36pm 20 Jun 2018 |
Copy link to clipboard |
 Print this post |
|
If the code is small then you might need the check the size of your variables and usually multidimensional arrays can use up a lot.
You will need to provide some more information to get useful help.
Which LCD Backpack are you using and what version of MM Basic are you running. you can PRINT the variables MM.VER and MM.DEVICE$ if you are not sure.
You can execute the MEMORY command to see how much memory is being used.
Let us know how you go or if you need more help. Edited by Azure 2018-06-22 |
| |
carlm Newbie
 Joined: 31/05/2018 Location: AustraliaPosts: 10 |
| Posted: 11:37pm 20 Jun 2018 |
Copy link to clipboard |
 Print this post |
|
Hi Panky,
I quickly did this on my cutdown code. The result follows: > RUN Flash: 2K ( 3%) Program (82 lines) 17K (29%) Library 41K (68%) Free
RAM: 0K ( 0%) 0 Variables 0K ( 0%) General 50K (100%) Free [56] Const DecWarning10 = 25 Error: Not enough memory
I am no expert but this seems to be OK.
Carl |
| |
panky
 Guru
 Joined: 02/10/2012 Location: AustraliaPosts: 1116 |
| Posted: 11:43pm 20 Jun 2018 |
Copy link to clipboard |
 Print this post |
|
Carl,
Can you post the entire program you ran above - you are right re the memory, that should not be the issue.
panky
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |
| |
carlm Newbie
 Joined: 31/05/2018 Location: AustraliaPosts: 10 |
| Posted: 11:50pm 20 Jun 2018 |
Copy link to clipboard |
 Print this post |
|
Hi, this is the entire code!
'Options memory option explicit option default none option autorun on 'Flags const True = 1 const False = 0 'IO const bFuelPulse = 17 CONST bFuelSolenoid = 16 'Pins setpin bFuelPulse, din ' pullup or pulldown setpin bFuelSolenoid, dout 'Globals used by Sub DrawButton CONST NumberOfButtons = 30 Dim Integer key_coord(150, 5) Dim String key_caption(150) Dim integer key_state(150), key_pulse(150) dim integer iMinWarning = 400 dim integer iMaxEmpty = 2000 dim integer iMinDiff = 100 dim integer iPulseCountSinceLastDose dim integer iDoseCountWarning dim integer iDoseCountEmpty dim integer iLitresPerDose = 10 dim integer iDosesSinceRefill dim string StandbyTitleA = "Standby"
dim integer iTemp 'GUI Controls (Main) - 1 > 10 Const MainNavtoEmpty = 1 Const MainNavtoWarning = 2 Const MainNavtoStandby = 3 Const MainNavtoValues = 4 'GUI Controls (Standby) - 11 > 20 const DosesReset = 11 Const StandbyNavToEmpty = 12 const StandbyNavtoStandby = 13 Const StandbyNavtoHome = 14 const StandbyNavtoValues = 15 'GUI Controls (Warning) - 21 > 30 const IncWarning1 = 21 const IncWarning10 = 22 const IncWarning100 = 23 const DecWarning1 = 24 const DecWarning10 = 25 const DecWarning100 = 26 const WarningNavToEmpty = 27 const WarningNavtoStandby = 28 Const WarningNavtoHome = 29 ' = 30 'GUI Controls (Empty) - 31 > 40 const IncEmpty1 = 31 const IncEmpty10 = 32 const IncEmpty100 = 33 const DecEmpty1 = 34 const DecEmpty10 = 35 const DecEmpty100 = 36 const EmptyNavToWarn = 37 const EmptyNavtoStandby = 38 Const EmptyNavtoHome = 39 ' = 40 'GUI Controls (Values) - 41 > 50 const IncMinDiff1 = 41 const DecMinDiff1 = 42 const IncMinWarn1 = 43 const DecMinWarn1 = 44 const IncMaxEmpty1 = 45 const DecMaxEmpty1 = 46 Const ValuesNavtoHome = 47
|
| |
Grogster
 Admin Group
 Joined: 31/12/2012 Location: New ZealandPosts: 9751 |
| Posted: 11:52pm 20 Jun 2018 |
Copy link to clipboard |
 Print this post |
|
Hmmmmm.....very interesting. I agree - this should not be an issue. I'm with Panky and Azure - please post your entire code, so we can examine it.
EDIT: Ha! Beat me!
EDIT: [code] Dim Integer key_coord(150, 5) Dim String key_caption(150) Dim integer key_state(150), key_pulse(150) [/code]
Your single string DIM is sucking up most of the memory. Each string reserves 256 bytes of memory, so 256 x 150 = 38,400 - 38K of RAM right there in that one single command. 
Try adding LENGTH commands to your strings. Lets say you KNOW the strings will be no more then 50 bytes: Dim String key_caption(150) LENGTH 50
That will create a single array of 150 elements, but each one will only be 50-bytes long. Edited by Grogster 2018-06-22 Smoke makes things work. When the smoke gets out, it stops! |
| |
Azure
 Guru
 Joined: 09/11/2017 Location: AustraliaPosts: 446 |
| Posted: 12:08am 21 Jun 2018 |
Copy link to clipboard |
 Print this post |
|
Depending on what chip you are using those arrays especially the string will take up a lot of the available memory.
You need to execute the memory command after you get the error.
@Grogster We are typing at the same time Edited by Azure 2018-06-22 |
| |
panky
 Guru
 Joined: 02/10/2012 Location: AustraliaPosts: 1116 |
| Posted: 12:53am 21 Jun 2018 |
Copy link to clipboard |
 Print this post |
|
Carl,
Grogster/Azure certainly have the problem right - your variables use up 51K and the MM2 chip only has 50K available.
Even with the suggestions above of using the LENGTH modifier in your DIM statement, your program looks to be moderately complex and if you want to take advantage of using the GUI commands, you might consider moving to the MM+ Backpack (Silicon Chip Nov 2016). With your program as is, you only use about half the variable memory of an MM+ so with some tidying as suggested by others, you will have tons of room for expansion.
panky
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |
| |
carlm Newbie
 Joined: 31/05/2018 Location: AustraliaPosts: 10 |
| Posted: 01:09am 21 Jun 2018 |
Copy link to clipboard |
 Print this post |
|
Thanks Guys, I through some smaller values straight into my original code arrays and it seems to be working again.
|
| |
Grogster
 Admin Group
 Joined: 31/12/2012 Location: New ZealandPosts: 9751 |
| Posted: 01:15am 21 Jun 2018 |
Copy link to clipboard |
 Print this post |
|
String arrays are a real memory gobbler.  Geoff added the LENGTH option to the DIM command for this reason. Earlier versions of MMBASIC did not have that option, and......well.....you just found out why it is a good thing to have in the language. Smoke makes things work. When the smoke gets out, it stops! |
| |