You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are coding caveats in plugin interfaces. Coding rules should be automatically checked to avoid issues.
For example:
classes (e.g. Datapoint) do not define their destructor as virtual. Thus it is impossible to define a sub-class because destructor will never be called, implying memory leaks (and inconsistent behavior)
(in south plugin) typedef void (*INGEST_CB)(void *, Reading); => Why is that passed by copy?. The documentation does not provide the actual definition of INGEST_CB (in https://fledge-iot.readthedocs.io/en/develop/plugin_developers_guide/03_south_C_plugins.html) This seems like a critical point because Readings copy imply a deep copy of Datapoints which may contain deep vectors of vectors of vectors ... Moreover there are a lot of useless copies of readings all during processing lifetime, thus leading to unefficient code execution
This is important to be able to derive clases, typically in scope of unit tests (For example I want to use a memory leak checker for datapoints in my unit tests:
class Datapoint_leak_chk : public Datapoint {
public:
Datapoint_leak_chk(const std::string& name, DatapointValue& value) :
Datapoint(name, value) {
instances.push_back(this);
LOG_WARNING(" TEST TODO : created %p", this);
}
virtual ~Datapoint_leak_chk(void) {
LOG_WARNING(" TEST TODO : deleted %p", this);
std::vector<Datapoint_leak_chk*>::iterator it;
it = std::find(instances.begin(), instances.end(), this);
assert (it != instances.end());
instances.erase(it);
}
static void resetNbInstances(void){
for (Datapoint_leak_chk* p: instances) {delete p;}
instances.clear();
}
static int getNbInstances(void){return instances.size();}
private:
static std::vector<Datapoint_leak_chk*> instances;
};
std::vector<Datapoint_leak_chk*> Datapoint_leak_chk::instances{};
some class members are not initialized (Reading).
The text was updated successfully, but these errors were encountered:
There are coding caveats in plugin interfaces. Coding rules should be automatically checked to avoid issues.
For example:
Datapoint
) do not define their destructor asvirtual
. Thus it is impossible to define a sub-class because destructor will never be called, implying memory leaks (and inconsistent behavior)typedef void (*INGEST_CB)(void *, Reading);
=> Why is that passed by copy?. The documentation does not provide the actual definition ofINGEST_CB
(in https://fledge-iot.readthedocs.io/en/develop/plugin_developers_guide/03_south_C_plugins.html) This seems like a critical point because Readings copy imply a deep copy of Datapoints which may contain deep vectors of vectors of vectors ... Moreover there are a lot of useless copies of readings all during processing lifetime, thus leading to unefficient code executionThis is important to be able to derive clases, typically in scope of unit tests (For example I want to use a memory leak checker for datapoints in my unit tests:
Reading
).The text was updated successfully, but these errors were encountered: