IE浏览器中的reloadGrid上的jqGrid内存泄漏

时间:2016-05-23 09:04:26

标签: javascript jquery json memory-leaks jqgrid

我正在尝试重新加载jqGrid,但每次reload trigger of jqGrid IE6浏览器使用的内存会增加,浏览器会挂起一段时间。我也尝试过我的手机,我的手机被挂了,加载jqGrid Data需要一些时间,经过reload jqGrid {移动浏览器jqGrid Version后很长一段时间才会死机。

jquery Version:4.4.3

jquery UI version:1.7.2

server:1.8.24

首先,我通过jquery帖子向data发出请求,然后我将jqGrid传递给$.post(this.actionURL, this.postData, function (data) { //my function is called to fill the jqGrid } 以填充。

我的代码:

jqGrid

如果不存在,则创建this.jqGridView.jqGrid({ datatype: "jsonstring", datastr: data, loadui: "block", jsonReader: { "repeatitems": false }, colNames: this.columnNames, colModel: this.columnModel, height: "auto", gridview: true, rowNum: '', ignoreCase: true, forceFit: true, autowidth: false, width: this.jqGridViewWidth, loadComplete: function () { } });

jqGrid

如果jqGrid存在,请重新加载 this.jqGridView.jqGrid("clearGridData"); this.jqGridView.jqGrid('setGridParam', { datatype: 'jsonstring', datastr: data }) .trigger("reloadGrid");

wbsCreate <- function(v) {
  wb <- createWorkbook()
  sheet <- createSheet(wb, "Sheet1")
  rows  <- createRow(sheet, rowIndex=1:5)
  cells <- createCell(rows, colIndex=1:5) 
  for (r in 1:5)
    for (c in 1:5)
      setCellValue(cells[[r, c]], value = v[(r-1)*5+c])
  saveWorkbook(wb, tf <- tempfile(fileext = ".xlsx"))
  return(tf)
}

wbsMarkDiff <- function(fn1, fn2) {
  fns <- c(fn1, fn2)
  wb <- lapply(fns, loadWorkbook)  
  cs <- lapply(wb, function(x) CellStyle(x) + 
                 Fill(backgroundColor="red", 
                      foregroundColor="red", 
                      pattern="SOLID_FOREGROUND"))
  sheets <- lapply(wb, getSheets)
  sheetnames <- do.call(intersect, lapply(sheets, names))
  for (sheetname in sheetnames) {
    sheet <- lapply(sheets, "[[", sheetname)
    rows <- lapply(sheet, getRows)
    cells <- lapply(rows, getCells)
    values <- lapply(cells, function(cell) lapply(cell, getCellValue))
    idx <- names(which(!mapply(identical, values[[1]], values[[2]])))
    for (s in 1:2) 
      for (i in idx) 
        setCellStyle(cells[[s]][[i]], cs[[s]])
    for (s in 1:2)
      saveWorkbook(wb[[s]], fns[s])
  }
}

library(xlsx)

# create to excel workbooks (same dimensions per sheet)    
v <- LETTERS[1:25]
tf1 <- wbsCreate(v)
v[c(3,6,9)] <- letters[c(3,6,9)]
tf2 <- wbsCreate(v)

# mark differences     
wbsMarkDiff(tf1, tf2)
shell.exec(tf1) # open file1 on windows
shell.exec(tf2) # open file2 on windows

问题:

  1. 每次重新加载jqGrid时,浏览器使用的内存都会增加。
  2. 我可以在屏幕上显示jqGrid后清除jqGrid数据吗?因此内存可以变得干净,jqGrid仍然显示数据。

0 个答案:

没有答案