D and a bazillion of small objects
Yao G.
nospamyao at gmail.com
Wed Jun 2 14:56:08 PDT 2010
Hello everybody.
What's the best practice or more efficient way to deal, in D, with lots of
small objects? My problem is this: I have a small control, ListView. This
control can have hundreds (and theoretically thousands) of items
(ListViewItem instances, to be precise). And, in turn each one of this
ListViewItems can own sub-items (ListViewSubItem instances), effectively
creating an humongous quantity of small objects.
Should I just go and create all of those items as classes? I have the
feeling that this not very efficient (a lot of small heap allocations).
There's also the possibility of make them structs. But then I would have
the issue of passing value objects in methods and losing whatever change I
made (because I would be modifying a copy of the original). To solve this
I could make an internal, Impl structure, and then use reference counting
to manage the copies and to make effective all the item modification
across all copies. But then I would be where I started: doing tons of heap
allocations.
So, how should I deal with this issue?
Thanks.
Yao G.
More information about the Digitalmars-d-learn
mailing list