Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #35838 > unrolled thread

Canvas resources

Started byJonas Thörnvall <jonas.thornvall@gmail.com>
First post2018-11-19 15:37 -0800
Last post2018-11-20 10:39 +0700
Articles 2 — 2 participants

Back to article view | Back to comp.lang.javascript


Contents

  Canvas resources Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-11-19 15:37 -0800
    Re: Canvas resources JJ <jj4public@vfemail.net> - 2018-11-20 10:39 +0700

#35838 — Canvas resources

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2018-11-19 15:37 -0800
SubjectCanvas resources
Message-ID<82218f1d-5297-4423-aaca-bca4487da7fc@googlegroups.com>
My script has one rendering canvas, but also a few more or less static information canvases. Editing, settings, instruments etc. These static cavases are "hidden?" in button contexts, and only shown when repective button pressed.

Now i wonder a bit about canvases, does all the canvases i created take up memory weither visible or not on screen? 

And does a static canvas also use any of the cpu? Can one, and should i, create and remove/revoke and reload the static canvases every time button the button for it pressed or is it just unnecessary work? 

If so how do one revoke "garbage collect?" a created canvas each time button closed?


[toc] | [next] | [standalone]


#35839

FromJJ <jj4public@vfemail.net>
Date2018-11-20 10:39 +0700
Message-ID<1qoy0jpna866t$.1v1fzii87zg8p$.dlg@40tude.net>
In reply to#35838
On Mon, 19 Nov 2018 15:37:46 -0800 (PST), Jonas Thörnvall wrote: 
> My script has one rendering canvas, but also a few more or less static
> information canvases. Editing, settings, instruments etc. These static
> cavases are "hidden?" in button contexts, and only shown when repective
> button pressed. 

By "hidden in button contexts", I think you meant stored as a local variable
in button event handler functions. Thus, not accessible elsewhere unless the
canvas is placed onto the document.

> Now i wonder a bit about canvases, does all the canvases i created take
> up memory weither visible or not on screen? 

Yes. Otherwise, where would the pixel information be stored? Not to mention
the canvas element's properties.

> And does a static canvas also use any of the cpu?

Yes. At least when it needs to be displayed in the viewport. Whether
hardware accelleration is used or not.

> Can one, and should i,
> create and remove/revoke and reload the static canvases every time button
> the button for it pressed or is it just unnecessary work? 

That'll only create garbages and temporarily waste memory. However, if
performance is more important than memory usage, and if resetting the state
of the canvas takes too long (for e.g. game restart/reset), the canvas can
be simply dumped then create a new one. Efficiency tend to be slow, and
performance tend to be memory hungry.

> If so how do one revoke "garbage collect?" a created canvas each time
> button closed?

You can't control the garbage collection process. You'll have to simply
"tuck" it in and hide it, then show it again when you later need it.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web