Will TCavnas::Clear() release the memory of everything on it?

Dear experts

Do I need to manually delete pointers of objects that already Drawn on a TCanvas after I call TCanvas::Clear()? e.g.:

TCanvas*c = new TCanvas();
TGraph* g = new TGraph();
TMarker* m = new Marker(1,1,22);
g->Draw();
m->Draw();

c->Clear();
//Do I need to do this?
//delete g;
//delete m;

Try to draw them after c->Clear() and see (note that you need to add at least 1 point to the graph in the first place).

Seems the sub-pads will be deleted but everything drawn on the pads will not.

When you create a graphics object, it exists independently. Drawing it does not transfer its ownership to the canvas/pad. You need to delete it if you want to free the associated memory.

So would it probably be better to use unique-ptrs instead?

auto c = std:::make_unique<TCanvas>();
auto g = std:::make_unique<TGraph>();
auto m = std:::make_unique<TMarker>(1,1,22);
g->Draw();
m->Draw();

c->Clear();

Or even valued variables?

TCanvas c{};
TGraph g{};
TMarker> m{1,1,22};
g.Draw();
m.Draw();

c.Clear();