Filtering Leads to Fatal Error: Allowed Memory Exhausted

Filtering Leads to Fatal Error: Allowed Memory Exhausted

NathanSFNathanSF Posts: 17Questions: 0Answers: 0
edited May 2012 in General
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]

Replies

  • allanallan Posts: 63,546Questions: 1Answers: 10,476 Site admin
    How is the filtering being done on the server-side? It sounds like you have an infinite loop somewhere in your PHP.

    Allan
  • NathanSFNathanSF Posts: 17Questions: 0Answers: 0
    It seems that $_GET['sSearch'] is not getting set, so we are not getting a value for $sWhere to apply a where clause to our query when filtering is applied. Working on this, will let you know when we get it figured out. If you have any info on $_GET['sSearch'] please let me know.

    [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]
  • NathanSFNathanSF Posts: 17Questions: 0Answers: 0
    We were joining multiple tables and had an ambiguous reference. Working now, thanks for input.
This discussion has been closed.