Filtering Leads to Fatal Error: Allowed Memory Exhausted
Filtering Leads to Fatal Error: Allowed Memory Exhausted
Our datatable is not exceptionally large, 7100 records. The original page load is fast, the issue occurs when we try to filter the results. When the first character is entered in the search box, we get 'JSON error from server could not be parsed'. Debug shows this is caused by 'Fatal error: Allowed memory size of 268435456 bytes exhausted'. The only other support thread I have found with this error is here:
http://www.datatables.net/forums/discussion/5796/sorting-and-loading-is-slow-for-server-side/p1
Tried adding fnSetFilteringDelay, but still getting the error. The filtered result is obviously a subset of the entire table, I haven't been able to figure out why the entire table can load but any filter attempt generates an error.
[code]
<!--
var dTablereportTable;
$(document).ready(function() {
dTablereportTable = $('#reportTable').dataTable({
"bProcessing": true,
"bJQueryUI": true,
"sDom": '<"clear"><"top ui-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix"lTf>rt<"bottom ui-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix"pi><"clear">',
"bAutoWidth": true,
"aoColumns": [{'sType':'html'},null,{'sType':'html'},null,null,null,{'bVisible':false},{'bVisible':false},{'bVisible':false},{'bVisible':true}],
"sAjaxSource": 'json_data.php',
"bStateSave": true,
"aaSorting": [[3,"desc"],[1,"desc"]],
"bServerSide": true,
"sPaginationType": "full_numbers",
"sScrollX": "100%",
"sScrollXInner": "100%"
});
});
-->
[/code]
http://www.datatables.net/forums/discussion/5796/sorting-and-loading-is-slow-for-server-side/p1
Tried adding fnSetFilteringDelay, but still getting the error. The filtered result is obviously a subset of the entire table, I haven't been able to figure out why the entire table can load but any filter attempt generates an error.
[code]
<!--
var dTablereportTable;
$(document).ready(function() {
dTablereportTable = $('#reportTable').dataTable({
"bProcessing": true,
"bJQueryUI": true,
"sDom": '<"clear"><"top ui-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix"lTf>rt<"bottom ui-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix"pi><"clear">',
"bAutoWidth": true,
"aoColumns": [{'sType':'html'},null,{'sType':'html'},null,null,null,{'bVisible':false},{'bVisible':false},{'bVisible':false},{'bVisible':true}],
"sAjaxSource": 'json_data.php',
"bStateSave": true,
"aaSorting": [[3,"desc"],[1,"desc"]],
"bServerSide": true,
"sPaginationType": "full_numbers",
"sScrollX": "100%",
"sScrollXInner": "100%"
});
});
-->
[/code]
This discussion has been closed.
Replies
Allan
[code]
function dtSearchClause($aColumnsFilter) {
$sWhere = "";
if(isset($_GET['sSearch']) && $_GET['sSearch'] != "") {
$sWhere = " AND ( (";
$searchString = explode(" ", $_GET['sSearch']);
foreach($searchString as $searchValue){
$filterColCt = count($aColumnsFilter);
for($i = 0; $i < $filterColCt; $i++) {
if(stripos($aColumnsFilter[$i], 'concat') === false)
$escapedSearchStr = mysql_real_escape_string($searchValue);
else
$escapedSearchStr = mysql_real_escape_string(str_replace(" ", "", $searchValue));
$sWhere .= $aColumnsFilter[$i] . " LIKE '%$escapedSearchStr%' OR ";
}
$sWhere = substr_replace($sWhere, "", -3);
$sWhere .= " ) AND ( ";
}
$sWhere = substr_replace($sWhere, "", -6)." )";
}
return $sWhere;
}
[/code]