rodw
Well-Known Member
- Joined
- Dec 2, 2012
- Messages
- 1,146
- Reaction score
- 340
I've been thinking about Carl's problem which I'm sure is related to memory overflows from a memory leak. Typically, leaks manifest when scode is called repeatedly. If this is the case it has to be in the external classes I'm using for forms and fields. I find the best way to solve problems is to leave them alone for a while to let the brain work its way though it.
I'm wondering if forms are not clearing themselves correctly when exiting a procedure. In the examples, all forms and fields were global variables and I moved them to procedures to free up memory. The printDivideVals is called every time you do a division so it is a very busy piece of code. It contains a form that is never used but I added it to format an angle. I'm wondering if the Field is not being erased correctly in exit.
I had some problems when testing 20 odd divisions this morning as afterwards I could not enter the Home menu so maybe this was enough for me to see the memory leak manifest itself on my system.
Carl, I'm wondering if you add this to the end of the procedure
as shown here.
In theory, the compiler should look after all of this for us but its worth a try. If this solves your problem, I know to go through all of the other procedures and explicitly remove all fields on exit in this way..
Please report back...
I'm wondering if forms are not clearing themselves correctly when exiting a procedure. In the examples, all forms and fields were global variables and I moved them to procedures to free up memory. The printDivideVals is called every time you do a division so it is a very busy piece of code. It contains a form that is never used but I added it to format an angle. I'm wondering if the Field is not being erased correctly in exit.
I had some problems when testing 20 odd divisions this morning as afterwards I could not enter the Home menu so maybe this was enough for me to see the memory leak manifest itself on my system.
Carl, I'm wondering if you add this to the end of the procedure
Code:
tempForm.removeField(&tempField);
as shown here.
Code:
void printDivideVals(int iDiv,long iAngle)
{
Form tempForm(lcd);
DegreeField tempField(tempForm, "", 360, DEGREEFIELD_READ_WRITE); // Just using this to convert to degrees
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Div: ");
lcd.print(iDiv);
lcd.print(" of ");
lcd.print(divisions);
tempField.setValue(iAngle);
tempField.printDegrees();
lcd.setCursor(10,1);
lcd.print(" / Div");
tempForm.removeField(&tempField);
}
In theory, the compiler should look after all of this for us but its worth a try. If this solves your problem, I know to go through all of the other procedures and explicitly remove all fields on exit in this way..
Please report back...