Re: Object creation overhead

From: Richard (richard_at_praxistech.com)
Date: 11/27/03


Date: Thu, 27 Nov 2003 00:03:32 GMT

Anthony Borla wrote:

>
> General approaches:
>
> * Reduce the size of each object
>
> - Use 'proxy' objects to represent each 'real' object.
> When the proxy is selected, the 'real' object is
> instantiated from data stored elsewhere [e.g. in
> a database, file, or cache]

Probably will have to do this, but I have not finalized an approach...

>
> - Minimise the number of fields in each object. For
> example, instead of using separate 'String' objects
> to store data such as 'subject', 'from', etc, just use a
> single 'StringBuffer' to hold *all* this data, and
> extract it from the 'StringBuffer' via accessors.
> The 'StringBufferReader/Writer' classes could help
> here
>
> - Use alternate means to represent object data. For
> example, instead of pbjects like 'String', encode data
> in 'int' primitives and decode using bitwise operations
> via accessors

How about using a primitive like char or char[]?

My main concern was the overhead of the String class, not much for a couple
of thousand Strings, but now I am dealing with upwards of 100,000...

The end result is that this ArrayList is used in a TableModel. Looks like I
have a lot of re-writing to do that I didn't want. Oh well, at least it
will perform better...

Thank you for your help!
Rich



Relevant Pages

  • Re: How to add thousand separators
    ... First, this code is obsolete as written, because char is a dead data type and should not ... Note that both of these should be stored as string resources since they might need to be ... 18 digits for any reason. ... you have made a VERY SERIOUS DESIGN ERROR. ...
    (microsoft.public.vc.mfc)
  • Re: what is the best way of passing floats into a string
    ... I do not null-terminate as snprintf takes care of this (according to ... But the easiest way to determine the size needed to format a number, ... int length_of_representation(double n,const char* format){ ... I get a nice result of -10.000000 in my char * string. ...
    (comp.unix.programmer)
  • Re: weird problem
    ... I already told you that the comparison between an integer and a float ... to strcmpwhich expects a pointer to a string. ... And now a question about something else: why do you use floating ... int,float, char, etc. ...
    (comp.lang.c)
  • Re: [OT] My First C# (warning - long post)
    ... cut me some slack - show me a COBOL program with less than 15 working-storage variables! ... Yes, the Trimis probably extra now, but that was my attempt to get it to quit griping at me that I had given it a "String", when it wanted a "char". ... public string IBreturn ...
    (comp.lang.cobol)
  • Re: why I can not write to the file after initialize the MFC in a service program
    ... you don't use char, an obsolete data type ... Why do you need an intermedate buffer to write literal strings anyway? ... For example, if AfxWinInit fails, you copy a 45-character string into a ... So you are going to try to initialize MFC EACH TIME THROUGH THE LOOP? ...
    (microsoft.public.vc.mfc)