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.
IndexProcessing DevelopmentCore,  Processing Development Environment (PDE) › Malloc'd memory state silly question
Page Index Toggle Pages: 1
Malloc'd memory state silly question (Read 1728 times)
Malloc'd memory state silly question
Jan 22nd, 2008, 9:42pm
 
I want to create a drawing/ rendering context without initialising the memory first, so that unless a background(255); type command is issued the user is presented with the dirty memory state subsequent to issuing the size(x, y, renderer); method.

Is this possible through modifying the processing source code, or does Java do some clean up that cannot be overridden?

Just need to know whether its possible, really. I'm downloading the source for a rummage, but thought I might save some time by asking first.

Many thanks.
Re: Malloc'd memory state silly question
Reply #1 - Jan 22nd, 2008, 10:07pm
 
Java always gives you clean memory.

To get the effect you want you could set every pixel to a random colour in setup();
Re: Malloc'd memory state silly question
Reply #2 - Feb 6th, 2008, 1:41pm
 
I doubt that's what mh wants-- the contents of memory would be more visually interesting than random noise (e.g. big sparse arrays would look stripy, images would be vaguely make-outable).

But anyhoo, it's true there's no way to do it in Java-- the VM sets all allocated space to zero as a security feature.

I think if you made a native method using JNI, you could malloc() memory in there, and return it so it could be copied into a PImage.  That would give you an image of discarded bytes from the JVM's heap.
Re: Malloc'd memory state silly question
Reply #3 - Feb 6th, 2008, 1:46pm
 
Thanks guys,

Gumbobo_Malloy is right about the desire for the visual impression associated with memory contents.

I'll look into the JNI as a workaround.
Page Index Toggle Pages: 1