We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Memory Leak: What am I doing wrong
Page Index Toggle Pages: 1
Memory Leak: What am I doing wrong? (Read 522 times)
Memory Leak: What am I doing wrong?
Apr 15th, 2010, 8:41am
 
http://www.stever.cc/FromScratch/applet/
Granted I could try to increase memory size. But I have a feeling I'm not cleaning up somewhere I should be. The reason I think it's a leak is that it takes a few seconds to happen.

Steve
Re: Memory Leak: What am I doing wrong?
Reply #1 - Apr 15th, 2010, 9:43am
 
Generic note: always call size() first in setup(). Code before size() is often called twice...

The design of the code is strange... did you wrote it to illustrate your problem or is that the end result you wanted to get?

The problem is that you can create a new PImage 60 times per second... Of course, all the previously created buffers should be garbage collected, but perhaps it can't act quick enough to clean up the memory.

The image being of fixed size, you can create the buffer in setup() and reuse it on each call.
Or just avoid to call blend_new() in draw(), but again it depends on your final objective.
Re: Memory Leak: What am I doing wrong?
Reply #2 - Apr 15th, 2010, 10:31am
 
Thanks
Creating the buffer in the setup worked.
Interesting thought about garbage collection not being able to keep up.  I'll have to keep that in mind.  Because the way I'd like this to work is to keep returning PImage like so:
d1=fade(d1);
d1=blur(d1);
d1=stretch(d1);
image(d1,0,0);

Similar to chaining in JQuery.

All this would be kept in the draw function and change based on frame rate


This code is a little weird. I am sort of playing around.
So unsure of my final objective. I think I want to make a graphics library that can help in creating animated poetry.
Page Index Toggle Pages: 1