parse-community / parse-embedded-sdks

The Embedded SDKs for the Parse Platform
http://parseplatform.org
Other
246 stars 118 forks source link

Memory leak #20

Closed cjevans76 closed 9 years ago

cjevans76 commented 9 years ago

Is there a worked example for periodically sending data from the yun up to parse? I tried the code below, but the board froze after a while. I used FreeMemory to look at the available memory and this seems to be the problem. I suspect I'm just not clearing the ParseCreate object correctly. Any tips?

include

include

include

define INTERVAL 60000 // one minute in ms

ParseClient client; static unsigned long lTimer; void setup() { // put your setup code here, to run once:

// Initialize digital pin 13 as an output. pinMode(13, OUTPUT);

// Initialize Bridge Bridge.begin();

// Initialize Parse client.begin("MY_KEY1", "MY_KEY2");

// initialise minute timer lTimer = millis();

// Initialize Serial Serial.begin(9600); Serial.println("Initialised"); }

void loop() { // timer if ( (long)( millis() - lTimer ) >= 0) { lTimer += INTERVAL; // do it again 1 interval later //periodic actions

// print memory state
Serial.print("freeMemory()=");
Serial.println(freeMemory());

// create and fill parse object
ParseObjectCreate create;
create.setClassName("TestData");
create.add("tStk", 550);
create.add("iPwrFc", 9.1);

// send data and get response
ParseResponse response = create.send();

// display response status
Serial.println("\nResponse for saving LogData:");
Serial.print(response.getJSONBody());
if (!response.getErrorCode()) {
  String objectId = response.getString("objectId");
  Serial.print("Test object id:");
  Serial.println(objectId);
} else {
  Serial.println("Failed to save the log data");
}
response.close();

} }

ronaldyang commented 9 years ago

@cjevans76 Thanks for submitting the issue. We are looking at this problem. Please stay tuned.

cjevans76 commented 9 years ago

For reference, the available memory seems to decrease every 15 or so loops round, not every loop. So with a minute between loops, it takes c. 15 minutes to see a drop in memory and c. an hour for the system to run out of memory altogether.

ronaldyang commented 9 years ago

@cjevans76 The fix is in this commit https://github.com/ParsePlatform/parse-embedded-sdks/commit/aae4cb3a5d65e1fbc1299af97abe3ecfb30f215 Let us know if the problem is still existing with this fix.

cjevans76 commented 9 years ago

@ronaldyang Thanks. I'll have a look this evening and let you know.

cjevans76 commented 9 years ago

Looks good so far (albeit with limited testing). I'll leave it running overnight to get a bit more data. Thanks for the quick turn-around.

cjevans76 commented 9 years ago

Still running after 10 hours so looks fixed.

ronaldyang commented 9 years ago

Sounds good. Closing this issue.

oms5 commented 9 years ago

Please update the Starter Project Link with this fix in the Quick Start guide.