Close



Results 1 to 10 of 396

Hybrid View

  1. #1
    Super Moderator Roxy's Avatar
    Join Date
    Apr 2014
    Location
    Lone Star State
    Posts
    2,182

    Memory leak....

    Dacb: Random new topic here: You modified the code to allocate space this way:
    (I might have already added this code to your branch of the Marlin tree... But I could not Sync it)

    Code:
    // "A" matrix of the linear system of equations
    double* eqnAMatrix = (double*)malloc(sizeof(double) * (n_points*n_points*3));
    // "B" vector of Z points
    double* eqnBVector = (double*)malloc(sizeof(double) * (n_points*n_points))
    This really is a better way of doing it than assumming the stack is deep enough to handle those large arrays. But we probably should check that the memory was available on the heap. We might want to add right after the malloc()'s something like:

    Code:
    if ( eqnAMatrix==NULL || eqnBVector==NULL) {
                SERIAL_PROTOCOLPGM("?Memory not available for Auto Bed Leveling.\n");
                if (eqnAVector)
                     free(eqnAVector);
                if (eqnBVector)
                     free(eqnBVector);
                break;
    }
    and the memory isn't free()'ed at the end. At some point, the Arduino board won't be able to do Auto Bed Leveling any more!

    Code:
    #endif  // ORIGIN_FRONT_RIGHT
    }
                set_bed_level_equation_lsq(plane_equation_coefficients);
    
                free(plane_equation_coefficients);
                free(eqnAVector);
                free(eqnBVector);
    #else // AUTO_BED_LEVELING_GRID not defined
    Mean while.... I've got my post processing script for Slic3r finding the print's size and modifying the G29 in the GCode file. I guess I'll use F, B, L, R for right now... But I think my vote is for using XMIN, YMIN, XMAX and YMAX.
    Last edited by Roxy; 09-27-2014 at 06:52 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •