This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3200 json.h library memory problem



Hello,

I had been using jsmn.h lib for JSON parser but I changed the library with json.h library in my project. I wrote code;

jsonParser parser;
jsonObj object;

object = json_parser_init(&parser, g_clogData);

rValue = (char*)malloc(128);
memset(rValue, NULL, sizeof(rValue));
rValue = json_object_get_string(&parser, object, "IR", rValue);

json_parser_deinit(&parser);
free(rValue);

It works but after 5-6 times my code doesn't work anymore because of memory fault. I don't understand which one causes memory problem? Is json.h library is stable about memory usage?

Turan

  • Hi,

    I haven't any experience with json parser library from SDK, but I have one advice. Avoid to use dynamic memory allocation as much as possible (malloc, calloc, etc.). With usage dynamic memory comes more issues (memory fragmentation, etc.) than advantages in embedded systems. My suggestion in your case is try to use static memory.

    Jan