leaks Event classes on every sensor change callback

Bug #1256953 reported by Martin Pitt
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
platform-api
New
Undecided
Ricardo Mendoza

Bug Description

./android/default/default_ubuntu_application_sensor.cpp creates a new *Event object for every sensor change, like e. g.

                ubuntu::application::sensors::AccelerometerEvent::Ptr ev(
                    new ubuntu::application::sensors::AccelerometerEvent(
                        reading->timestamp,
                        reading->acceleration[0],
                        reading->acceleration[1],
                        reading->acceleration[2])
                        );

                on_accelerometer_event(
                    make_holder(ev), this->context
                    );

but this never gets deleted, so this is a rather big memory leak (as at least on my device accelerometer events happen several times a second even when not moving it).

Ricardo and I quickly discussed how the API should behave -- whether Event* can potentially live forever and need an explicit _free() method (that would be new API), or whether the getters for Event* are only valid during the callback (on_*_event) and immediately freed. We both agreed that the latter is sufficient and much simpler (clients don't need to remember to free events every time).

So this needs some "delete ev;", and presumably this make_holder() stuff can go away entirely.

Ricardo Mendoza (ricmm)
Changed in platform-api:
assignee: nobody → Ricardo Mendoza (ricmm)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.