gzz-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Jython memory inefficiency [Was: Re: [Gzz] 28th-29th (jvk)]


From: Janne Kujala
Subject: Jython memory inefficiency [Was: Re: [Gzz] 28th-29th (jvk)]
Date: Wed, 30 Oct 2002 14:27:58 +0200
User-agent: Mutt/1.2.5i

On Wed, Oct 30, 2002 at 12:45:30PM +0200, Tuomas Lukka wrote:
> On Wed, Oct 30, 2002 at 12:34:05PM +0200, Janne Kujala wrote:
> > It seems that the problem is string concatenations like
> > 
> >     for i in range(0,4):
> >         code += """
> >         %s %s
> >         TexCoord %s
> >         """ % (("Color", "SecondaryColorEXT")[using_secondary_color],
> >                js(cols[i]), js(texcoords[0][i]))
> > 
> >         for u in range(1,len(texcoords)):
> >             code += """
> >             MultiTexCoord TEXTURE%s %s
> >             """ % (u, js(texcoords[u][i]))
> > 
> >         code += """
> >         Vertex %s
> >         """ % js(vertices[i])
> > 
> > 
> > If I add that piece of code many times, the thrashing begins
> > much sooner.
> > 
> > Is there a way to construct the strings more efficiently?
> 
> Yes, there is. Use an array of strings:
> 
>       code = [],
>       code += ["""...
>       """]
>       and finally
>       code = "".join(code)
> 
> much more efficient.

No difference: I still can only press some keys 23 times before
thrashing begins -- even if I leave out the final join.

If I put the above code fragment four times in the code, 
I can only press keys 9 times.

If I leave out the code fragment, I can press keys 44 times.

The code is executed 8 times for each of the key presses.

When the thrashing begins, java process memory size grows from
about 180M to 930M. After that, I can press keys 6400 times
while memory size grows to about 1050M. Then, I get
        
        Out of Memory
        You might want to try the -mx flag to increase heap size

I'm using Sun's j2sdk1.4.1_01.

Any ideas?

        jvk




reply via email to

[Prev in Thread] Current Thread [Next in Thread]