app_main() memory model / multi-threading
Posted: Thu Nov 21, 2019 2:56 pm
Towards the end of my latest sprint I have gained a new, strange exception.
The sprint added a memory hungry library and so I have been forced to start using PSRAM. AFAIK PSRAM is only used by the new libary as will only be allocated if malloc size > 32K and I still have internal RAM left.
The exception happens in app_main() initialisation within CreateDataBase() (I do not see the "Created" output).
Partial code to illustrate placement of masking code relative to the exception point.
My question is, why would extracting a value from the 'model' at the end of initialisation prevent an exception being raised during the model's creation?
'model' is supplied to both the Front Panel & WebApplication 'views' & so must have been created.
EDIT: I wrapped the data item creation process with a try/catch and the problem items are std::string.
Once I add the enabling line then I no longer get an exception.
Is this a library issue then e.g. using the item brings in the correct library?
The sprint added a memory hungry library and so I have been forced to start using PSRAM. AFAIK PSRAM is only used by the new libary as will only be allocated if malloc size > 32K and I still have internal RAM left.
The exception happens in app_main() initialisation within CreateDataBase() (I do not see the "Created" output).
Partial code to illustrate placement of masking code relative to the exception point.
Code: Select all
printf("Creating data\n");
model = CreateDataBase();
printf("Created\n"); // Not seen when exception raised
broker = new DeviceBroker(interfaceProcessor, model);
view = new FrontPanelView(broker, model, hwci->Buttons(), hwci->Leds());
view->Start();
WebApplication *webApplication = new WebApplication(model, settings, broker, hwci);
webApplication->Start();
// Adding these lines avoids the exception
vTaskDelay((1000) / portTICK_PERIOD_MS);
volatile std::string modeString = GetDatabaseValue<std::string>(model, DeviceModelString);
'model' is supplied to both the Front Panel & WebApplication 'views' & so must have been created.
EDIT: I wrapped the data item creation process with a try/catch and the problem items are std::string.
Once I add the enabling line then I no longer get an exception.
Is this a library issue then e.g. using the item brings in the correct library?