ParallelGraphics Forums
Cortona VRML Client
You are here: [Forums]::[Browsers]::[Cortona VRML Client]

Registration 
Registration
Forgot your password?

Help 
Help
Support

Quick search 

Subscribe to newsletters 

Install Cortona VRML Client for FREE!
Outline 3D
Try RobinZone!
email:  password:
   Browsers - Cortona VRML Client

Subject: sending a coordIndex to IFS results in memory leak
Sender: michaelusachov@mail.ru 16.08.08 09:07

Hi all,
This example (simplified fragment of real developed now application) has memory leak when running (few minutes of working and -- 'out of memory'), possibly because a coordIndex value sends each simulation tik.
What is wrong, and how avoid this leak ?
BS Contact and Octaga works ok.

#VRML V2.0 utf8

Shape {
appearance Appearance {
material Material { diffuseColor .47 .59 .38 }
}
geometry DEF IFS IndexedFaceSet {
creaseAngle 0.78 coord Coordinate {}
}
}

DEF    Clock TimeSensor { loop TRUE enabled TRUE }

DEF    Program Script {
directOutput TRUE mustEvaluate TRUE
field SFNode thisScript USE    Program
field SFNode ifs USE IFS
field SFNode tmr USE Clock
field SFInt32 segs_Y 128
field SFInt32 segs_X 128
field MFInt32 coordIndex_copy []
eventIn SFTime loop
url "javascript:

function initialize () {

// create plane

var
vIdx_Y, vQuan_Y = segs_Y + 1,
vIdx_X, vQuan_X = segs_X + 1,
point, coord_point = ifs.coord.point,
scale = 1;
coord_point.length = vQuan_Y * vQuan_X;
for ( vIdx_Y = 0; vIdx_Y < vQuan_Y; ++vIdx_Y ) {
for ( vIdx_X = 0; vIdx_X < vQuan_X; ++vIdx_X ) {
point = coord_point[ vIdx_Y * vQuan_X + vIdx_X ];
point.x = scale * vIdx_X;
point.y = scale * vIdx_Y;
point.z = 0;
}
}

var
fIdx_Y, fQuan_Y = segs_Y,
fIdx_X, fQuan_X = segs_X,
coordIndex = coordIndex_copy,
idx_coordIndex = 0;
coordIndex.length = 5 * fQuan_Y * fQuan_X;
for ( fIdx_Y = 0; fIdx_Y < fQuan_Y; ++fIdx_Y ) {
for ( fIdx_X = 0; fIdx_X < fQuan_X; ++fIdx_X ) {
coordIndex[ idx_coordIndex++ ] = fIdx_Y * vQuan_X + fIdx_X;
coordIndex[ idx_coordIndex++ ] = fIdx_Y * vQuan_X + fIdx_X + 1;
coordIndex[ idx_coordIndex++ ] = ( fIdx_Y + 1 ) * vQuan_X + fIdx_X + 1;
coordIndex[ idx_coordIndex++ ] = ( fIdx_Y + 1 ) * vQuan_X + fIdx_X;
coordIndex[ idx_coordIndex++ ] = -1;
}
}

ifs.set_coordIndex = coordIndex;

// create route from time sensor

Browser.addRoute( tmr, 'time', thisScript, 'loop');

}



function loop ( t ) {

// randomly choose a f

var
fIdx_Y = Math.floor( segs_Y * Math.random() ),
fIdx_X = Math.floor( segs_X * Math.random() ),
idx_coordIndex = 5 * ( fIdx_Y * segs_X + fIdx_X ),
coordIndex = coordIndex_copy;
                
// and switch it off
coordIndex[ idx_coordIndex++ ] = -1;
coordIndex[ idx_coordIndex++ ] = -1;
coordIndex[ idx_coordIndex++ ] = -1;
coordIndex[ idx_coordIndex++ ] = -1;
coordIndex[ idx_coordIndex++ ] = -1;

// apply current state each simulation tik
ifs.set_coordIndex = coordIndex;
}

"
}

 


sending a coordIndex to IFS results in memory leak / michaelusachov@mail.ru / 16.08.08 09:07
     Re: sending a coordIndex to IFS results in memory leak / michaelusachov@mail.ru / 16.08.08 19:25
         Re: sending a coordIndex to IFS results in memory leak / michaelusachov@mail.ru / 16.08.08 19:32

Messages in thread: 3


© 1998-2007 ParallelGraphics. All rights reserved. Terms of use.