Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STARsolo: Possible memory leak in SoloFeature_cellFiltering.cpp #1619

Open
ScottNortonPhD opened this issue Aug 2, 2022 · 1 comment
Open
Labels
issue: code Likely to be an issue with STAR code
Milestone

Comments

@ScottNortonPhD
Copy link

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
@alexdobin alexdobin added the issue: code Likely to be an issue with STAR code label Aug 3, 2022
@alexdobin
Copy link
Owner

Thanks for catching it Scott!

@alexdobin alexdobin added this to the Bugs milestone Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: code Likely to be an issue with STAR code
Projects
None yet
Development

No branches or pull requests

2 participants