Jump to content

Issue with context 2d


chaucer
 Share

Recommended Posts

I've recently found something slightly odd when creating a texture from a canvas, I was hoping someone could help me understand what exactly is happening, as well as if theres a solution to the issue. The problem I'm encountering, is that anytime I create a texture from a canvas, and call...
 

canvas.getContext( '2d' );

 

my ram consumtion seems to go higher than if I don't call the getContext function. This isn't the only issue though, as anytime i try to clear the texture, the ram that the texture consumed doesn't seem to be freed either. Here's a screenshot to show the comparision.

Untitled.thumb.png.84c8a5a65792dcbf489e952cd92823f5.png

In both examples, I've created a blank canvas with the size of 10,000x10,000( just for testing purposes ). The only difference in each example, is that the top screenshot does not call getContext, while the bottom one does. You can see quite a large difference in the amount of ram consumed, as well as that the memory isn't cleared in the bottom one, even after removing it's parent and destroying it. 

If anyone can provide any insight as to why this is happening or has a solution to the issue, I'd greatly appreciate it. :D

Link to comment
Share on other sites

That's 10 5k monitors. That's at least 10k$ . 

Anyway, try "d=null" after all that. And there's no guarantee about when browser actually frees that memory. Also no guarantees about free videomemory, whether its still allocated or not. Try repeat that 10 times and see the result

Link to comment
Share on other sites

@ivan.popelyshev Haha, yeah, I don't actually use any canvas objects that size, I was just using it so that the ram usage was more visible, the issue happens to me on smaller images as well, it's just easier to see with a larger canvas. I'd previously tried setting the canvas to null, as well as setting it's size back down to 0 before doing so, I also tried as @Exca suggested, and tried forcing garbage collection, however my ram still does not free up, and again, it's only when the canvas.getContext('2d') is called, which really strikes me as odd, reguardless It's not that big of a deal I guess, mostly it's just a curiosity to me. Also the ram DOES eventually free up on it's own( just not all of it ) if i let it run for about 5 minutes. Also I just had another person try this out, and on their end it seemed to work fine for both examples, so it might just be something to do with hardware(?),  since I've already checked drivers, and ran several scans to make sure everythings running smooth on my computer. Either way thanks for the words of advice, it's much appreciated :D

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...