Tagged Questions
-1
votes
0answers
11 views
Can calling many setTimeouts per frame create garbage collection overhead?
Game programming context, 60 fps. Assume that no garbage collection overhead is created otherwise. Can creating many timeouts per frame generate garbage collection overhead? Will I have to worry about ...
0
votes
1answer
42 views
PhoneGap Garbage Collection
I had a long discussion with my friend about PhoneGap. He said that PhoneGap has no garbage collection scenario. I searched for Javascript garbage collection and found the following links:
What is ...
4
votes
2answers
56 views
How can I log what is being garbage collected in my javascript code?
I've built an application that wastes 40% of its time collecting garbage, and I'm at my wits' end trying to find out where it is coming from. I've corralled any possible problems in my own code, yet ...
0
votes
0answers
27 views
Does checking for function exists prevent browser garbage collection from freeing memory?
I have JavaScript in file A which loads file B (through a jquery AJAX load) into element X. On success, file A calls resizewin (below) which checks if the function resizeContent exists (which was in ...
0
votes
0answers
31 views
Qt and JavaScript Garbage Collection
I am looking for a way to call the JavaScript garbage collector from within QWebFrame. I have searched the Qt Docs and have found the QWebFrame::addToJavaScriptWindowObject method. I think this may be ...
2
votes
1answer
97 views
How do I create a memory leak in JavaScript?
I would like to understand what kind of code causes memory leaks in JavaScript and created the script below. However, when I run the script in Safari 6.0.4 on OS X the memory consumption shown in the ...
0
votes
0answers
36 views
How can I delete objects from memory in JavaScript?
I am using EaselJS and Box2DWeb to create an arrow shooting game. Every time an arrow collides with another body, it dies, and I call this function:
if(body.dead){
removeActor(body.GetUserData()) ...
23
votes
4answers
478 views
DOM: why is this a memory leak?
Consider this quote from the Mozilla Docs on JavaScript memory leaks:
function addHandler() {
var el = document.getElementById('el');
el.onclick = function() {
...
1
vote
0answers
22 views
non attached Image.onload garbage collection
If an image is created via var img=new Image(), an onload handler is added and img.src is set, the image data will be requested, and onload called despite the image is not attached to the DOM tree. ...
0
votes
2answers
21 views
Does the GC-Logic works in all Browsers the same?
I trying to understand a bit more about Garbage collection. I am currently using Google Chrome's Tools like Speed Tracer, Timeline and Profiles for our web app.
I made a simple test and counted all ...
0
votes
0answers
61 views
Will reinitializing a JavaScript object at global scope cause a memory leak?
I have links in a JQuery DataTable that use JQuery UI's tooltip feature. Each link has a tooltip that is populated by an Ajax call. I would like to limit the number of Ajax calls to as few as ...
2
votes
2answers
43 views
Will arguments make an object non-collectible by JavaScript GC?
var person = {
name: 'John'
};
function Pet1(person) {
var owner = person.name;
this.showOwner = function() {
alert(owner);
}
}
function Pet2(person) {
this.showOwner = ...
2
votes
2answers
57 views
How does a global “window” reference affect garbage collection in an iife?
function BigObject() {
var a = '';
for (var i = 0; i <= 0xFFFF; i++) a += String.fromCharCode(i);
return new String(a); // Turn this into an actual object
}
// iife 1 / window gets ...
8
votes
1answer
109 views
Does Chrome's javascript garbage collection work differently? [duplicate]
When I try to debug this code (http://jsfiddle.net/QWFGN/)
var foo = (function(numb) {
return {
bar: function() {
debugger;
return "something";
}
}
...
3
votes
1answer
84 views
JS Strings/Numbers and Garbage Collection
tl;dr
Does the following line of code create an object (like a JavaScript String object or a JavaScript Number object) to combine the string primitive and the number?
var scouterSays = "powerlvl" + ...
3
votes
1answer
79 views
Why is this new code slower than my old code?
The question
I have replaced some code that I was having performance issues with with some new code that I had expected to perform better. Instead, it performed worse. I'd like to understand why this ...
-1
votes
1answer
99 views
Javascript garbage collection
I have base class which extends Backbone.View class.
I pass a Jquery DOM element through the constructor, is this object a candidate for garbage collection?
var MainView = BaseView.extend({
...
0
votes
1answer
53 views
Garbage collection and closures on local variables
Will xmlHttp get garbage collected and if so, when ?
function foo (param)
{
var xmlHttp = GetXmlHttpRequestObject();
xmlHttp.onreadystatechange = function()
{
if ...
3
votes
1answer
92 views
Is the Monolithic God object in Javascript a performance concern?
The way it is:
I have recently joined a webapp project which maintains, as a matter of standard, one single globally-available (ie, itself a property of window) object which contains, as properties ...
1
vote
1answer
28 views
Can an object be garbage collected if a reference to one of it's members still exists?
In Javascript, it is my understanding that items are garbage collected when no references to them exist on the page.
var obj = {
arr: [1,2,3]
};
var arr = obj.arr;
obj = "hello";
In the above ...
0
votes
0answers
54 views
How can I find a Javascript variable pointing to a certain object, using Chrome Profiler?
I've just jumped in the middle of a project, and have to investigate a huge amount of code, and find a memory leak.
This legacy stuff is written in Ext.js 3 and 4. We have different type of assets and ...
0
votes
1answer
82 views
JavaScript Garbage Collection on nested objects (DSL Development)
I want to create a DSL-like builder for my javascript object, but i'm not sure that DSL-Builder object is removed by garbage collector (created object). Here's the code:
function Section() {...}
...
1
vote
1answer
52 views
Are JavaScript<->DOM circular references safe in modern browsers?
I'm building an AJAX app that makes heavy usage of tables displaying data. To keep the design simple it's nice to be able to tie table rows (DOM) to the data objects (JavaScript) and visa-versa. So, ...
0
votes
0answers
46 views
Removing jQuery from a document (garbage collection)
I'd like to know if it's possible to remove executed JS code from a document. Let's say I've loaded jQuery, but I no longer need it, is it viable to simply run delete window.$ and such or is there a ...
13
votes
2answers
413 views
Garbage collection of unneeded event listeners in javascript
I am building a single page webapp. This means over a period of time I get new DOM elements, remove unneeded ones. For example when I fetch a new form I just replace the contents of a specific div ...
1
vote
2answers
74 views
Can values be stored without allocating memory?
I have been reading here
https://developer.mozilla.org/en-US/docs/JavaScript/Memory_Management#Allocation_via_function_calls
and these lines confused me a bit:
var s = "azerty";
var s2 = ...
1
vote
1answer
64 views
JavaScript patterns and garbage collection
I've been using two versions of a JavaScript pattern for a while that I picked up from Addy Osmani called the module pattern. view it here
The first version of this pattern uses an object literal:
...
3
votes
2answers
104 views
Do javascript objects inside of an array erase from the memory when I clear the array?
I never really gave much thought to garbage collection and I don't know whether or not it is necessary to take into account when making small javascript games/applications. Any advice is appreciated, ...
3
votes
1answer
66 views
Is it necessary to delete callback function after being called/executed in JavaScript?
I have a web-app that polls for data periodically to 3rd party services (say Facebook, Twitter, and so on).
This poll/request is made via JSONP (to avoid cross-domain issue).
For example, a simple ...
0
votes
0answers
86 views
Memory Leaks, Garbage Collection and Best Practice of Coding for Web browser, iPad and iPhone [closed]
i would like to get some information regarding the best practice of coding of JavaScript for avoiding memory leaks, how can i release the memory manually for better performance of application in ...
17
votes
3answers
146 views
Does it make sense to attempt to assist the JavaScript Garbage Collector?
As I more heavily use JavaScript like a high-level object-oriented language, I find myself thinking like the C/C++ programmer that I am when I'm finished with objects. I know the GC is going to run ...
3
votes
1answer
105 views
JavaScript, Memory Leaks, Garbage Collection. Trying for easy way out?
let's say I have a 'magical' function like so... (magical will be explained)
var arr = ['hello','I','am','in','an','array'];
(function() {
var z = document.getElementById('z');
//before ...
9
votes
2answers
1k views
Forcing garbage collection in Google Chrome
We are developing a single-page web app with ZK which constantly communicates with server and updates parts of its screens. Updating can be as frequent as 1s. During these updates, references to large ...
1
vote
1answer
202 views
JQuery - Detecting DOMNodeRemoved on self / garbage collection
I apologize for the bad title, but I'm not sure how to word this. I have logic that is attached to elements, and would like a destructor-like function to be called whenever the element is removed. ...
16
votes
3answers
416 views
Event handlers, closures and garbage collection in Javascript
I'm not running into a memory leak in my application yet, but I'm worried about possible problems in the future. I would like to know if doing something like this:
SomeClass.prototype.someMethod= ...
4
votes
1answer
91 views
Closure and garbage collection: most efficient way to remove consecutive nodes from a linked list
I wrote a quick and dirty implementation of a doubly-linked list for javascript. I would like to be able to remove multiple (consecutive) nodes at once, and was wandering: is it enough to just sever ...
0
votes
1answer
84 views
Local Variables and GC
I'm trying to wrap my head around private variables in Javascript, temporary variables, and the GC. However, I can't quite figure out what would happen in the following situation:
MyClass = ...
1
vote
3answers
218 views
Javascript: make an deep clone/extend/copy function that does not make any garbage for GC
I would like to make an extendDeep() function that does not make any garbage for GC.
The garbage collector need to be as inactive as possible.
ref.: ...
3
votes
5answers
79 views
Does assigning a new string value create garbage that needs collecting?
Consider this javascript code:
var s = "Some string";
s = "More string";
Will the GC have work to do after this sort of operation?
(I'm wondering whether I should worry about assigning string ...
5
votes
2answers
150 views
Does JavaScript garbage collect this?
Every once in a while I find myself doing something along the lines of the following
var img = new Image();
img.src = 'php/getpic.php?z=' + imid + '&th=0';
img.onload = ...
1
vote
1answer
79 views
Javascript Garbage collection for inline code
We've In-Line Javascript data like following with thousand of lines.
I've observed that it is taking lot of memory too, this is a problem in mobile browsers.
Does it help to move this code to some ...
1
vote
0answers
54 views
Is there a systematic way to determine where GC-pause causing objects are being instantiated with chrome developer tools?
It's clear from looking at the memory timeline that the severe pauses I am witnessing in my javascript execution are a result of garbage collection. What isn't clear is which objects are causing this ...
0
votes
2answers
69 views
mark and sweep in javascript(context variable)
i am reading Professional JavaScript for Web Developers
i got problem when reading "When the garbage collector runs, it marks all variables stored in memory. It then clears its mark off of variables ...
17
votes
2answers
1k views
node.js / Express throws 'RangeError: Maximum call stack size exceeded' under high load
We are having an issue with our node environment running under high
load that we have not been able to find the source of.
A little background: we are running a clustered node application using
...
1
vote
1answer
94 views
Which way is better when we're focus on garbage collecting?
Simple question, what is better for Garbage Collector:
adding object to array and assigning null to array cell
this.requests[i] = new NiceClass();
this.requests[i] = null;
creating simple ...
0
votes
1answer
137 views
Does V8 garbage collection free memory?
I was reading the V8 docs and it says that the garbage collector "reclaims" memory.
My question is does it "reclaim" the memory to be used in its own heap or does it free it?
Thanks in advance.
1
vote
2answers
349 views
Get current time in Javascript without creating Date object?
I implement custom double/triple/other clicks in my javascript app, but I'm concerned with garbage-collection pauses. Is there a way to obtain current time with milisecond precision without creating ...
2
votes
2answers
157 views
Garbage collection in JavaScript closures
I need some help here to undestand how this works (or does not, for that matter).
In a web page, I create a click event listener for a node.
Within the listener, I create an instance of some ...
0
votes
1answer
74 views
Is it possible to induce significant garbage collection pauses in Chrome with their incremental garbage collector? [closed]
Something over 250 ms, for example? Or is it very hard to do now?
2
votes
2answers
95 views
How can I determine what objects are being collected by the garbage collector?
I have significant garbage collection pauses. I'd like to pinpoint the objects most responsible for this collection before I try to fix the problem. I've looked at the heap snapshot on Chrome, but ...