Jump to content

memory was exhausted


KenChuang
 Share

Recommended Posts

HI all, 

Im trying draw a lot of sprite but Google chrome tried to show this page when the memory was exhausted. I want to use on the Wafer.

var circle = new PIXI.Graphics();
circle.beginFill(0xff0000);
circle.drawCircle(3, 3, 1);
var texture = circle.generateCanvasTexture();
for (var i = 0; i < 4000000; i++) {
  var sprite = new PIXI.Sprite(texture);
  sprite.x = Math.random() * 900;
  sprite.y = Math.random() * 400;
  app.stage.addChild(sprite);
}

Is there any way to solve this problem?
thanks

 
Link to comment
Share on other sites

On 2017/6/30 at 8:47 PM, ivan.popelyshev said:

Dont make more than 100k sprites, 4kk is too much.

If they're static, you can create renderTexture, then after you spawn every 4k of them, draw them to renderTexture, then change their position, draw them again, and then you'll have texture with 4kk circles on it :)

HI,
This is what I want to draw things, but this is inside each piece is not the same, each of which has 8k information, according to this real information to draw a bit.

How can I do to reduce the use of memory, so that all The information is drawn out?
 

let defect = new PIXI.Graphics();    
let _strlength = this.str.length;
defect.beginFill(0x0000FF);           
defect.drawRect(0, 0, 1, 1);
let def_texture = defect.generateCanvasTexture();
for (let o = 0; o < 1127; o++) {  //1127chip
   this.chipPostion(this.chip_xy[o].Chipx, this.chip_xy[o].Chipy);   
      for (let j = Number(this._height) - 1; j >= 0; j--) {  
        let y = _h * j;
        for (let i = 0; i < _strlength; i++) {     
          let x = _w * i;
          if (this.arr[o][Number(this._height) - 1 - j][i] === '1') {
            this.sprite = new PIXI.Sprite(def_texture);
            this.sprite.x = init_x + x + this.chipx * (_strlength * _w);
            this.sprite.y = init_y + y + this.chipy * (Number(this._height) * _h);
            this.sprite.width = _w;
            this.sprite.height = _h;
            container.addChild(this.sprite);
          }
        }
     }
}

 

 

Link to comment
Share on other sites

1 hour ago, JeremyG said:

Is there a lot of change on each frame ?
If not , may be you shoud generate a canvas per square then  draw and update it when need
(May be you can generate a full canvas too ?)

No, refers to rendering once.

I think it does not work because addChild (this.sprite) will take up memory, if each can generate a canvas per square will cause such a problem.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...