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 : Memory Issues
Author | Message | ||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 926 |
Recently I found some software I wrote for QB45 on an IBM XT and thought it may be a good project to convert it to run on the Maximite. I have come across a stumbling block and hope the wealth of knowledge attached to this forum may be able to help me. The main issue is "Error: not enough memory" Here are the statistics: MEMORY 48kB (58%) Program (1283 lines) 29kB (34%) 18 Variables 2kB ( 3%) General 4kB ( 5%) Free Like the early Basics, is there a memory saving in placing multiple lines in one line? Is there a simple way we can we use the abundance of memory on the SD Card? Are there any other tricks to maximise the use of available memory? (Sorry about the pun) Looking forward to your suggestions. |
||||
Gizmo Admin Group Joined: 05/06/2004 Location: AustraliaPosts: 5078 |
Are there any data statements within the program that could be saved as text files on the SD card? One trick I used was storing chunks of data in different text files, and then reading in the text file when and only when you need that data. Remember reading from a SD card is fast, its writing thats slow and wears the card out. Also you can reuse variables, and clear them after use. Glenn The best time to plant a tree was twenty years ago, the second best time is right now. JAQ |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3199 |
Each line consumes two extra bytes of memory compared to using the colon to separate commands - so you do not save much by joining lines. You could load and run programs on the fly using the RUN command but that is very messy to use and requires you to save session data to the SD card. Probably the best memory saver is to strip out all comments and shorten literal strings. Geoff General note: Please understand if I go silent for the next month (I have rented an apartment in Rome and it has no Internet - which is probably a good thing). Geoff Graham - http://geoffg.net |
||||
bigmik Guru Joined: 20/06/2011 Location: AustraliaPosts: 2914 |
A well earned break Geoff, Enjoy the peace and quiet (If I could only remember that quote from `The Castle' but I am sure it will be quoted here before you check your bags). Have a great time and I am sure that all of the TBS's, as do I, wish you an enjoyable break. Regards, Mick Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 926 |
Gizmo, I read & save all initial and end variables to a data file on the SD card and I dont have any data stements in the program. Geoff, I will strip out all the comments and see how much extra memory I can gain. I am very envious of your forthcoming vacation, have a great time and look forward to your work in the future. |
||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 926 |
I have stripped out all comments and indents, abbreviated where possible and have the following stats: MEMORY 39kB (47%) Program (1115 lines) 29kB (35%) 18 Variables 2kB ( 3%) General 14kB (15%) Free Now the program tries to run but I still don't have enough memory to run the editor. Is there any other way of editing (no line numbers) without having to do it on the PC and reloading the program each time? |
||||
djuqa Guru Joined: 23/11/2011 Location: AustraliaPosts: 447 |
Which version of MMbasic and configuration of the Maximite are you using? You can edit the program directly without line numbers on the Maximite hardware with version 3.1 or later. VK4MU MicroController Units |
||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 926 |
Djuqa, Version 3.1 only permits 30KB for program memory and it seems the program I wish to convert is around 40KB. I am using MMBasic version 4.0 and have tried CGMMSTICK1 as well as Duinomite. My original intention was to make use of one of these units with this project but as I said in an earlier post they don't have enough room to run the editor. I can run the editor on the Maximite (not sure why when it says it has only 9KB free and the other units have 14KB) so it looks like I will have to do the coding and testing on the Maximite. |
||||
BobD Guru Joined: 07/12/2011 Location: AustraliaPosts: 935 |
If you run version 3.2C you should get enough memory. If I recall correctly, it had a shared memory pool which should allow enough for your program. |
||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 926 |
BobD, Please correct me if I am misled but the issue may not be the MMbasic version but the fact that I only have around 84KB of total memory available after the Basic is loaded. In this instance the program, variables and general memory use up 77KB. I have been looking for ways of economising on the use of this memory. |
||||
isochronic Guru Joined: 21/01/2012 Location: AustraliaPosts: 689 |
Just a question, is that right, 18 variables requiring 27 kbytes memory ? That is over a kbyte per variable ? cheers |
||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 926 |
chronic, That is right, all the variables declared are arrays and half of them are string arrays. I think the string arrays are very memory hungry. |
||||
James_From_Canb Senior Member Joined: 19/06/2011 Location: AustraliaPosts: 265 |
Yep, strings and their arrays are memory hungry. Try commenting out the line where you define each of the string arrays and check the resulting memory usage, then replace some of the big memory hogs with files on the SD card. You could also work out the biggest memory memory hogs with a calculator because strings are all fixed length (if I recall correctly), so the arrays with the biggest number of entries will be the first candidates for replacement. James My mind is aglow with whirling, transient nodes of thought careening through a cosmic vapor of invention. Hedley Lamarr, Blazing Saddles (1974) |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6103 |
Strings are a fixed 256 bytes. memory
dim test$(128) memory If your strings are short, can you combine them for storage? Four 64 byte strings (63 with an end character) would be a big saving. Jim VK7JH MMedit MMBasic Help |
||||
mattma Newbie Joined: 01/10/2012 Location: AustraliaPosts: 25 |
I ran into the same problem at 1280 lines of code too. it must be a magic number. I was wondering if any of the MM source code hackers here think it might be possible to use the A: drive space for program storage? With the SD card available it seems that we could live without the A: drive for file storage. Maybe it could be used to store libraries of functions that are 'called'/loaded when then are called and this would leave the main program memory for memory only. Does anyone know if this is possible? Anyone know how to do it? Cheers Matt |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6103 |
You might be able to make use of the RUN command. The first program has the menu and it can then RUN different programs to do their own thing, returning to the main menu using the RUN command. Or: the first program collects the data and the second one runs the analysis. This is the sort of thing I had to resort to in the 'good old days' of Microbee and ZX81. Be careful with the A drive, the flash memory has a limited number of read/write cycles and accessing the A drive might cause the display to flash. Jim VK7JH MMedit MMBasic Help |
||||
shoebuckle Senior Member Joined: 21/01/2012 Location: AustraliaPosts: 189 |
Another feature you may be able to use is to define an array just before you need to use it and "Erase" it when you have finished with it. Erasing it frees up the memory it occupied. Cheers, Hugh |
||||
aargee Senior Member Joined: 21/08/2008 Location: AustraliaPosts: 255 |
Ahh, a much more pleasant time to visit Rome than when we were there (early July) - enjoy yourself and the exchange rate! - Rob. For crying out loud, all I wanted to do was flash this blasted LED. |
||||
mattma Newbie Joined: 01/10/2012 Location: AustraliaPosts: 25 |
Is it possible to add more memory to the PIC32? |
||||
Print this page |