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

[Java3Djp:00182] Re: java.lang.OutOfMemoryError



えんどうです。

メモリー不足の原因は分かりませんが、

> for(int i=0; i<i1; i++){

>     	grid = new Shape3D(geom, createAppearance(img[i], res));

> }

Texture 以外のオブジェクトも同様ですが、
ループの中で毎回インスタンスを生成していますよね。

ループの外であらかじめ生成して使いまわすようにできると良いと思います。

あと、やったことがないのですが、
javax.media.j3d.ImageComponent のモードで By Reference というのがあるので
試してみるのも良いかも知れません。

> * By Reference:  A new feature in Java 3D version 1.2
>  allows image data to be accessed by reference,
>  directly from the RenderedImage object.
> To use this feature, you need to construct an ImageComponent object
>  with the byReference flag set to true.
> In this mode, a reference to the input data is saved,
>  but the data itself is not necessarily copied
>  (although it may be, depending on the value of the yUp flag,
>  the format of the ImageComponent, and the format of the RenderedImage). 
> Image data referenced by an ImageComponent object must not be modified. 
> Applications must exercise care not to violate this rule. 
> If any referenced RenderedImage is modified after it has been passed
>  to an ImageComponent object, the results are undefined. 
> Another restriction in by-reference mode is that
>  if the specified RenderedImage is not an instance of BufferedImage,
>  then this ImageComponent cannot be used for readRaster
>  or off-screen rendering operations, 
> since these operations modify the ImageComponent data.

-- 
ENDO Yasuyuki <yasuyuki@xxxxxxxxxxxx>
http://www.javaopen.org/~yasuyuki/ (Personal/Japanese Only)
http://www.javaopen.org/jfriends/ (Japanese Only)