Viewed   79 times

I got a problem I am submitting a simple form that has a small data and when I checked in the console tab the URL of ajax seems to be working but after the ajax was processed it will alert an error and it is redirected to my homepage and from the console tab I have this weird error:

Uncaught exception: out of memory

In my ajax I have this simple code only:

$("#add-comment").on('click', function() {

    var id = $('input[name='review_id']').val();
    var customer_id = $('input[name='customer_id']').val();
    var $comment = $('textarea[name='user_comment']').val();

    var sample = "test";

        url: 'index.php?route=product/product/writeSubComment',
        type: 'post',
        dataType: 'json',
        data: { text: sample },
        beforeSend: function() {

        success: function(data) {
        error: function() {


In my PHP controller I have this function

public function writeSubComment() {

    $json = array();

    $json['test'] = $this->request->post['text'];

    $this->response->addHeader('Content-Type: application/json');




From your description of being redirected to your homepage, but having no code in your ajax response sections to do this, I suspect that the element #add-comment is a submit button in your form.

If this is the case, then your form may be submitting at the same time the ajax code is running when you click the #add-comment submit button. This would explain the out of memory error as the ajax javascript is being expunged while the page redirects.

You would need to prevent your form from submitting, and let the success() or failure sections handle the next step (i.e. refreshing the page, updating the comments box). One way to do this would be to change

$("#add-comment").on('click', function() {


$('#add-comment').on('click', function(event){ 

or change the submit button from

<button type="submit" ...>Add comment</button>


<button type="button" ...>Add comment</button>

or change the form tag like this

<form onsubmit="return false;">

This is my best guess from the information I have available.

Friday, November 25, 2022

This answer provides the necessary modifications to your code.

DISCLAIMER: Without seeing the exact install, be aware there may be a variety of factors that cause this to not work "as-is" in your installation. I do not know how your routes are set up, or if you are using Firebug or some other console to watch the ajax calls, but this should give you the building blocks:

First, change your php to output the array as a json-encoded string:

public function getCars(){

        $this->form_validation->set_rules('carId', 'carId', 'trim|xss_clean');

            $carId = $this->input->post('carId');
            $carModels = $this->user_management_model->getCarModels($carId);
            // Add below to output the json for your javascript to pick up.
            echo json_encode($carModels);
            // a die here helps ensure a clean ajax call
        } else {
            echo "error";

Then, modify your script ajax call to have a success callback that gets the data and adds it to your dropdown:

function myFunction(obj)
    var dropDown = document.getElementById("carId");
    var carId = dropDown.options[dropDown.selectedIndex].value;
            type: "POST",
            url: "/project/main/getcars",
            data: { 'carId': carId  },
            success: function(data){
                // Parse the returned json data
                var opts = $.parseJSON(data);
                // Use jQuery's each to iterate over the opts value
                $.each(opts, function(i, d) {
                    // You will need to alter the below to get the right values from your json object.  Guessing that / d.modelName are columns in your carModels data
                    $('#emptyDropdown').append('<option value="' + d.ModelID + '">' + d.ModelName + '</option>');

Again - these are the building blocks. Use your browser console or a tool such as Firebug to watch the AJAX request, and the returned data, so you can modify as appropriate. Good luck!

Sunday, November 27, 2022

Your code works if you remove dataType: 'json', just tested it.

$('#save').click(function() {
  var tmp = JSON.stringify($('.dd').nestable('serialize'));
  // tmp value: [{"id":21,"children":[{"id":196},{"id":195},{"id":49},{"id":194}]},{"id":29,"children":[{"id":184},{"id":152}]},...]
    type: 'POST',
    url: 'save_categories.php',
    data: {'categories': tmp},
    success: function(msg) {
Wednesday, August 3, 2022


On your computer, one of the linker heaps is too small for this project. The project links with Link with Dynamic RTL option, because in that case the linker needs less memory, and the heap just happens to be large enough.

You can use -GH linker option to increase that heap, but first you have to find out which heap overflows. To do that, enable diagnostic output in the linker.

Compiling with diagnostic output

Compiling from the command line:

call rsvars
MSBuild /v:diag YourProject.cbproj

Compiling from the IDE:

  • Go to Tools > Options > Environment Options
  • Change Verbosity to Diagnostic
  • After building the project, read output from the Output tab of the Messages window

Increasing heap sizes

Near the end of the output, you should find sizes of heaps, similar to this:

The "ILINK32" task is using "ilink32" from "c:program files (x86)embarcaderostudio18.0binilink32.exe".
Turbo Incremental Link 6.75 Copyright (c) 1997-2016 Embarcadero Technologies, Inc.
Overrun on linker heap: tds
Linker Heaps
system                 0x030d4000  0x08000000
tds                    0x08710000  0x09400000
c:program files (x86)embarcaderostudio18.0BinCodeGear.Cpp.Targets(3517,5): error : Fatal: Out of memory
The command exited with code 2.

In this case, overflow happened in heap tds, so we need to increase its size. The left column gives the number of bytes in use, and the right column gives the number of bytes allocated. The new size should be larger than the value that is currently in the right column.

In this case, tds size was 0x09400000, so we increase it to 0x0f400000 with the following option: -GHtds=0x0f400000.

In the IDE, go to Project > Options > C++ Linker. Add -GHtds=0x0f400000 to Advanced > Additional Options.

After saving project options, compile the project again. If the same heap overflows, you need to increase its size even more. If another heap overflows, you need to increase its size as well.

For example, if code heap overflows now, and you want to increase its size to 0x0a000000, you should change Additional Options to -GHtds=0x0f400000 -GHcode=0x0a000000.

If you increase the heap too much, you will get LME288 error instead. That means you have reached the maximum size for some heap. If even the maximum size is not enough for your project, it seems C++ Builder 10.2.3. has doubled the maximum size, so you could migrate to that version, or copy ilink32.exe from 10.2.3. installation to use with an older version of C++ Builder.

More details

  • How to report a C++ Compiler or Linker problem and workarounds
  • "Unable to perform link" error when compiling in RAD Studio XE8

Did this not fix the problem?

  • If you are using C++ Builder 10.0 or 10.1, try to patch your linker as described here: LME288 Error in C++ Builder
  • If you are using C++ Builder 10.2, patching the linker does not work, but you can try other solutions in the same link
  • C++ Builder 10.2. has settings for managing heaps: Handling Out of Memory Errors
Wednesday, December 7, 2022

Read the file line by line, it will help you to avoid OutOfMemoryException. And I personnaly prefer using using's to handle streams. It makes sure that the file is closed in case of an exception.

public static void ToCSV(string fileWRITE, string fileREAD)
    using(var commas = new StreamWriter(fileWRITE))
    using(var file = new StreamReader("yourFile.txt"))
        var line = file.ReadLine();

        while( line != null )
            string q = (y.Substring(0,15)+","+y.Substring(15,1)+","+y.Substring(16,6)+","+y.Substring(22,6)+ ",NULL,NULL,NULL,NULL");
            line = file.ReadLine();
Monday, October 3, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :