Forum
15:50
18/11/2009
Hello,
I've detected a possible memory leak (with innerHTML=""). The following solution fixed it (for me)...
Modified: jquery.jqGrid.js
emptyRows = function (parent, scroll) {
var tBody = $("tbody:first", parent);
if(!ts.p.gridview || ts.p.jqgdnd) $("*",tBody).children().unbind();
- if(isMSIE) $.jgrid.empty.apply(tBody[0]);
- else tBody[0].innerHTML="";
+ // fix to get embedded widgets destroyed
+ $('tr', tBody[0]).remove();
I also tried the jQuery-empty()-function, but this did not destroy embedded widgets (as tooltips bound to table rows) so I used the jQuery-remove()-function.
20:09
Moderators
30/10/2007
Hello Klaus,
will be happy if you post a test case.
Also in which browser is this?
The main purpose of emptyRows is exactley not to use jQuery remove or empty.
The reason for this is that these work very slow in grid with rows >= 200.
The last line of code in this function should do the magic
tBody = null;
This line should release all the memory
Best Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
10:30
18/11/2009
Hello Tony,
The memory leaks seemed to be across several browsers (IE, Firefox).
I hope you didn't misunderstand - not the jqGrid itself has a memory leak - but any jQuery widget attached to the grid will not be destroyed correctly but keeps somewhere in memory.
The only solution (I found) to destroy those attached widgets (e.g. context menues or special tooltips on cells or rows) was by calling the jQuery remove method.
here is the code how I create my context menu widgets:
var gridCompleteFunction = function() {
$("tr.jqgrow", "#my_table").contextMenu({menu: "tableMenu"}, ...);
...
}
// create and open context menue directly on right click cell on grid
var onRightClickCellFunction = function(rowid, iRow, iCol, event) {
var cellElem = event.target;
$(cellElem).contextMenu({menu: "tableMenu2"}, ..., "doOpenDirectly");
}
The other possiblity would be to have an event when a row (or a set of rows) is removed from the table with the row objects given as parameter.
Or maybe you could provide a global option to decide which cleaup routine is taken in the emptyRows function (the "fast" or the "destructive" way )
Kind regards,
Klaus.
11:02
Moderators
30/10/2007
Hello Klaus,
I understand, since this is connected with the grid.
Could you please try this. Lieve the emptyRows as of its original variant and just remove the
if(!ts.p.gridview || ts.p.jqgdnd) – i.e the final code should be:
emptyRows = function (parent, scroll) {
var tBody = $("tbody:first", parent);
$("*",tBody).children().unbind();
if(isMSIE) $.jgrid.empty.apply(tBody[0]);
else tBody[0].innerHTML="";
if (scroll && ts.p.scroll) {
$(">div:first", parent).css({height:"auto"}).children("div:first").css({height:0,display:"none"});
parent.scrollTop = 0;
}
tBody = null;
},
If you test it this way, please let me know if this resolve the problem
Thanks
Best Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
15:51
18/11/2009
Hello Tony,
No, your suggestion did not help with my problem. The mentioned statement (
) will only unbind all events but will not clean up the following ...
- any created jQuery / jQuery UI widgets
- DOM elements and JavaScript objects (created manually or within a jQuery UI widget)
For example when I attach jQuery Tooltips on cells in the table, they create some JS objects and some DOM elements (DIVs) directly on the body.
So the only solution to remove those objects was using the remove method which will then invoke the widget's destroy method.
Kind regards,
Klaus.
11:02
Moderators
30/10/2007
Hello Klaus,
Yes you are right on this.
Will see what I can do for this. Thanks.
Best Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
45 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66