It looks like you're new here. If you want to get involved, click one of these buttons!
Hi all,
When I do something like this inside a method which I call often:
...
p = [ DPoint::new(0, 0), DPoint::new(6000, 0), DPoint::new(6000, 3000), DPoint::new(0, 3000) ]
poly = DPolygon::new(p)
view.zoom_box(poly.bbox.enlarged(10.0,10.0))
marker.set_polygon(poly)
...
and I do not call _destroy for the DPoints, the DPolygon and the implicitly generated DBox
do I generate a lot of dead objects occupying my memory?
Or do I have to write:
...
p = [(a=DPoint::new(0, 0)), (b=DPoint::new(6000, 0)), (c=DPoint::new(6000, 3000)), (d=DPoint::new(0, 3000)) ]
poly = DPolygon::new(p)
a._destroy; b._destroy; c._destroy; d._destroy
view.zoom_box(a=poly.bbox.enlarged(10.0,10.0))
a._destroy;
marker.set_polygon(poly)
poly._destroy;
...
???
Thank you in advance.
Frank
Ps: What tag could I use to create the nice colored code snipplets?
test=test
Comments
Hi,
last question first: you can use Markdown here. My way to marking code is to separate code by a single like with three backticks.
Regarding the "_destroy" question: Basically you don't need to destroy objects at all. In Python and Ruby, objects are destroyed when they are not longer required. In Python this happens through reference counting, Ruby has a garbage collection scheme which occasionally cleans up memory.
However, there are some scenarios this method can be useful:
Regards,
Matthias