Jquery .remove() + garbage collector or clear.

For developers using the Construct 2 Javascript SDK

Post » Thu Dec 26, 2013 10:55 am

Changing the URL of the iframe, or removing the iframe entirely, will remove all the memory the game uses. Since Javascript is a garbage-collected language it's possible it doesn't all disappear immediately. You might need to wait for it to get cleaned up.
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,351

Post » Thu Dec 26, 2013 1:24 pm

Sorry but I think the iframe is a very bad practice:

1- Lose the interaction with the site.
2- Consume the same memory, and for user waiting 5 or 10 minutes for browser decide to empty the memory is horrible.
3- We need interaction Normal Web With the C2 for a better designs or web aplications


I have a magic temporary solution :P (C2 MAGIC).

When finish the game I go to a clear layout with black background and On start of layout execute the javascript fuction to remove, and the C2 consumition are reduced to a minimun.


Thanks guys for the intension to help me.


Sorry for my english.


Greetings.- Onsterion2013-12-26 13:24:54
B
5
S
1
Posts: 21
Reputation: 525

Post » Thu Dec 26, 2013 9:52 pm

[QUOTE=Onsterion]
1- Lose the interaction with the site.
[/QUOTE]

Thats only true if you dont know how to do it ^_^

There are simple javascript approaches to getting info from a top window from within the iframe, such as .parent()

You can even call functions from an iframed window which are defined in the page holding the iframe.


I dont see how your trick would work any different by loading a less cpu intense layout ... the project is still loaded in to memory, images and all, from all layouts.


An export to html5 stil has a simple index file which you can fill with any kind of javascript or even PHP if you like :)
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Fri Dec 27, 2013 2:16 am

I don't like iframes

With this trick can reduce the memory usage of 750 to 50 mb. I think it's a good trick :P
B
5
S
1
Posts: 21
Reputation: 525

Post » Fri Dec 27, 2013 2:01 pm

iframes work fine. It should clear memory within seconds, not minutes. It should interact with the page just fine.
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,351

Post » Fri Dec 27, 2013 2:43 pm

I don't know why but if I use a iframe the custom loader doesn't work.
The loader bar do nothing.

I use "clamp (0, (loadingprogress * 488.5), 488.5)"Onsterion2013-12-27 14:57:54
B
5
S
1
Posts: 21
Reputation: 525

Post » Fri Dec 27, 2013 7:46 pm

you got it hosted somewhere ? can I take a look at the page ?
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Previous

Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 1 guest