0

I have a nested object with many nesting layers. Each object is basically containing list of some other types. I need to create a huge number of objects of these (almost 100 K) in short duration, and then discard them and then again create new. I wanted to understand whats the best way of pooling such kind of objects. Should I pool the whole object (the list member count for different objects may be different, or should I pool the last object E, though its very small ). Any suggestions are welcome.

ClassA
{
    int a;
    List<ClassB> mList;
}
ClassB
{
    int b;
    List<ClassC> mList;
}
ClassC
{
    int b;
    List<ClassD> mList;
}
ClassD
{
    int b;
    List<ClassE> mList;
}
ClassE
{
    int a ;
    int b;
    List<int> bcd;
    List<string> efg;

}
Rajesh Gaur
  • 287
  • 5
  • 11
  • This sounds like a highly overcomplicated design. Is the nesting really necessary? – MicroVirus Sep 15 '14 at 18:45
  • 1
    Try pooling different objects, profile the code, and see what happens. It's going to be so dependent on the specific data, usage, quantities, etc. that just trying it out is likely the best option. – Servy Sep 15 '14 at 18:45
  • @MicroVirus what would you suggest as an alternative? – Servy Sep 15 '14 at 18:46
  • @Servy Can't mention alternatives if one doesn't know the actual design requirements/situation/code. – MicroVirus Sep 15 '14 at 18:50
  • Just wanted to ask, List if I initialize its size, then its sort of become a pool, is my understanding correct. – Rajesh Gaur Sep 16 '14 at 00:59

0 Answers0