Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
My website eats RAM like a fat boy eats cake
Old 01-27-2010, 08:59 AM My website eats RAM like a fat boy eats cake
MoForce's Avatar
Super Talker

Posts: 145
Name: Jack Shalt
Trades: 0
My website eats RAM (client's RAM) like a fat boy eats cake and I suspect it's due to javascript running functions every second. Anyone know how I can stop this? I've used all browsers and it's the same across the board. Site opens and within 10min 50MB+ of RAM is use... 1 hour later and about half a gig is gone.

Last edited by MoForce; 01-27-2010 at 09:33 AM..
MoForce is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-27-2010, 09:03 AM Re: My website eats RAM like a fat boy eats cake
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
make sure that objects are destroyed when finished is the first thing.


Second is:

WHY are you running scripts every second?????????
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-27-2010, 09:32 AM Re: My website eats RAM like a fat boy eats cake
MoForce's Avatar
Super Talker

Posts: 145
Name: Jack Shalt
Trades: 0
Thanks, I'll look into it
it's an ajax powered live chat that I made myself
MoForce is offline
Reply With Quote
View Public Profile
 
Old 01-27-2010, 10:05 AM Re: My website eats RAM like a fat boy eats cake
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
setInterval is not a very efficient function, which I assume you must be using to make repeated requests. It consumes a lot of resources when it runs for a long time, though there could be some other bottlenecks in your code.

Maybe you should consider letting the chat go into "idle mode", where if there is no mouse movement after a certain time it stops requesting new information from the server.

Do you mind linking to the code, or are you keeping it private?
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 01-27-2010, 10:06 AM Re: My website eats RAM like a fat boy eats cake
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Aha! Ok. do you reuse the XMLHTTP object or recreate it on each iteration?


BTW Java applets are more suited to "chat" systems because they run in the context of the JVM which is more efficient on resource use than browsers are.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-27-2010, 10:21 AM Re: My website eats RAM like a fat boy eats cake
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
You may want to read this: How JavaScript Timers Work because he specifically talks about timers and how they work on the browser level, especially when used in conjunction with asynchronous events, which includes clicks and mouse movement other mouse events, not just the XMLHttpRequest object.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.

Last edited by wayfarer07; 01-27-2010 at 10:32 AM..
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 01-27-2010, 01:22 PM Re: My website eats RAM like a fat boy eats cake
MoForce's Avatar
Super Talker

Posts: 145
Name: Jack Shalt
Trades: 0
Quote:
Originally Posted by wayfarer07 View Post
setInterval is not a very efficient function, which I assume you must be using to make repeated requests. It consumes a lot of resources when it runs for a long time, though there could be some other bottlenecks in your code.

Maybe you should consider letting the chat go into "idle mode", where if there is no mouse movement after a certain time it stops requesting new information from the server.

Do you mind linking to the code, or are you keeping it private?
That's exactly what I'm doing! It's nothing special, just a setInterval that loads a php page into a div every 1 second.

I've been browsing the web recently and found this
http://www.ape-project.org/

would implementing that solve my problem? and are there other alternatives?

Last edited by MoForce; 01-27-2010 at 01:33 PM..
MoForce is offline
Reply With Quote
View Public Profile
 
Old 01-27-2010, 01:42 PM Re: My website eats RAM like a fat boy eats cake
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
From How JavaScript Timers Work
Quote:
setTimeout(function(){
/* Some long block of code... */
setTimeout(arguments.callee, 10);
}, 10);

setInterval(function(){
/* Some long block of code... */
}, 10);


These two pieces of code may appear to be functionally equivalent, at first glance, but they are not. Notably the setTimeout code will always have at least a 10ms delay after the previous callback execution (it may end up being more, but never less) whereas the setInterval will attempt to execute a callback every 10ms regardless of when the last callback was executed.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 01-27-2010, 03:17 PM Re: My website eats RAM like a fat boy eats cake
vilyanurchandra's Avatar
Super Talker

Latest Blog Post:
Elephants can’t jump!
Posts: 101
Name: Subash Chandra Poudel
Trades: 0
I think you should use free chat services like cbox.

that way you will not get RAM problem due to javascript.
__________________

Please login or register to view this content. Registration is FREE
vilyanurchandra is offline
Reply With Quote
View Public Profile Visit vilyanurchandra's homepage!
 
Old 01-30-2010, 03:39 PM Re: My website eats RAM like a fat boy eats cake
MoForce's Avatar
Super Talker

Posts: 145
Name: Jack Shalt
Trades: 0
Quote:
Originally Posted by wayfarer07 View Post
I finally got a chance to implement it... it looks like it works

Thanks for the help!
__________________

Please login or register to view this content. Registration is FREE
- FlUIN
MoForce is offline
Reply With Quote
View Public Profile
 
Old 02-03-2010, 06:28 AM Re: My website eats RAM like a fat boy eats cake
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
So did this solve your memory problem also?
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 02-22-2010, 08:24 PM Re: My website eats RAM like a fat boy eats cake
MoForce's Avatar
Super Talker

Posts: 145
Name: Jack Shalt
Trades: 0
Quote:
Originally Posted by wayfarer07 View Post
So did this solve your memory problem also?
It solved the memory problem for me! =)

Only thing though... it caused another problem =(

So now whenever someone types something in a form on the site characters are skipped when typing the moment the div associated with the above script refreshes... I find that this only happens on the firefox browser (chrome works fine... IE is just crap so I don't care about that). Any ideas?

edit: LOL I just tested the site in IE and guess what... no problems! So I guess it's just firefox
__________________

Please login or register to view this content. Registration is FREE
- FlUIN

Last edited by MoForce; 02-22-2010 at 08:49 PM..
MoForce is offline
Reply With Quote
View Public Profile
 
Old 02-24-2010, 11:32 PM Re: My website eats RAM like a fat boy eats cake
MoForce's Avatar
Super Talker

Posts: 145
Name: Jack Shalt
Trades: 0
any ideas on this one? I've never heard of javascript affecting non-javascript using form elements
__________________

Please login or register to view this content. Registration is FREE
- FlUIN
MoForce is offline
Reply With Quote
View Public Profile
 
Old 02-24-2010, 11:57 PM Re: My website eats RAM like a fat boy eats cake
SpecHosting's Avatar
Super Talker

Posts: 142
Name: Tanner Bradley
Location: Knoxville Tennessee
Trades: 0
Quote:
Originally Posted by MoForce View Post
any ideas on this one? I've never heard of javascript affecting non-javascript using form elements
You could set it to run default in Firefox by CSS, if that is an option in what you are doing.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
Servers Dedicated Servers

Please login or register to view this content. Registration is FREE
Now Offering: FREE WHMCS Licenses|FREE SSL Certificate|End User Support

SpecHosting is offline
Reply With Quote
View Public Profile
 
Old 02-25-2010, 11:04 PM Re: My website eats RAM like a fat boy eats cake
MoForce's Avatar
Super Talker

Posts: 145
Name: Jack Shalt
Trades: 0
Quote:
Originally Posted by SpecHosting View Post
You could set it to run default in Firefox by CSS, if that is an option in what you are doing.
How do you do that?
__________________

Please login or register to view this content. Registration is FREE
- FlUIN
MoForce is offline
Reply With Quote
View Public Profile
 
Old 02-26-2010, 10:25 PM Re: My website eats RAM like a fat boy eats cake
SpecHosting's Avatar
Super Talker

Posts: 142
Name: Tanner Bradley
Location: Knoxville Tennessee
Trades: 0
Google is great. Heres a link to show you how to do this! Hope it helps. http://www.thesitewizard.com/css/excludecss.shtml
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
Servers Dedicated Servers

Please login or register to view this content. Registration is FREE
Now Offering: FREE WHMCS Licenses|FREE SSL Certificate|End User Support

SpecHosting is offline
Reply With Quote
View Public Profile
 
Old 04-08-2010, 02:49 PM Re: My website eats RAM like a fat boy eats cake
Junior Talker

Posts: 1
Trades: 0
Wow, thanks for posting that link SpecHosting! I had no idea that you could have a different stylesheet for each browser..lol.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

Last edited by johnniedice; 04-08-2010 at 02:51 PM..
johnniedice is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to My website eats RAM like a fat boy eats cake
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.49962 seconds with 12 queries