Skip to content

STARsolo: Possible memory leak in SoloFeature_cellFiltering.cpp #1619

@ScottNortonPhD

Description

@ScottNortonPhD

The following array allocated using new[] at line 77 should be deleted but never is.

    bool *geneDetected = new bool[featuresNumber]; //=true if a gene was detected in at least one cell
    memset((void*) geneDetected, 0, featuresNumber);

Suggestion 1: Add the following statement at or after line 116:

     filteredCells.nGeneDetected=0;
     for (uint32 ii=0; ii<featuresNumber; ii++) {
         if (geneDetected[ii])
             filteredCells.nGeneDetected++;
     };
+    delete[] geneDetected;

Suggestion 2: Replace with a std::vector

-    bool *geneDetected = new bool[featuresNumber]; //=true if a gene was detected in at least one cell
-    memset((void*) geneDetected, 0, featuresNumber);
+    std::vector<bool> geneDetected (featuresNumber); //=true if a gene was detected in at least one cell; default-initialized to false

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue: codeLikely to be an issue with STAR code

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions