JSON解析 - 内存依赖?

I'm trying to pass very large arrays to JavaScipt to be manipulated client-side, and it's not working. These arrays typically have about 12,000 elements each, and this snippet of code is functioning correctly when I only plug in 2,000 elements.

    <script type="text/javascript">

        var getLenders = JSON.parse('<?php echo json_encode($getlenders); ?>');
        var discountArray = JSON.parse('<?php echo json_encode($discountArray); ?>');
        var getData = JSON.parse('<?php echo json_encode($sortedArray); ?>');

    </script>

I increased the memory requirements of the server to 512MB (4 time as much as before) thinking that'd be more than enough, however it is still not working. Before I crank up the memory to 1024MB, I would like to know if there is any other reason this is not working. Could it be an issue with client-side memory?

Any input is appreciated.

I'm sure this not good idea truly, Because you can't know you client has enough memory to run your page or not and this page freeze the browser or crash it.

first you can optimize this code to:

    var getLenders = <?php $a =  json_encode($getlenders);  echo $a == null? '{}': $a; ?> ;
    var discountArray = <?php $b =  json_encode($discountArray); echo $b == null? '{}': $b;  ?>;
    var getData = <?php $c = json_encode($sortedArray); echo $c == null? '{}': $c; ?>;

because json based on JavaScript and not need convert to string and parse again.

Second but I have one idea: get only needed value with ajax when you need them.

Don't.

Handling such a big amount of elements is not profitable. It's bad for your server, which generates somehow the array, and it's bad for your clients that have to deal with the huge amount, and sincerely, I dont think the client need to display all that data in a single run. Why you don't think about an ajax implementation which load the data only when it needs?

You should implement it with pagination. So maybe just display 100 entries at once that can be edited and sorted by headline. Then the user can decide to view the next 100 entries by clicking on a next link. Then you do an AJAX request to fetch the data and update your website. jQuery should be sufficient for the job.