-
Notifications
You must be signed in to change notification settings - Fork 46
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
Failing unit tests - memory leaks? #151
Comments
Same command, but failing test was at |
Heck; I'll have a look at this next week. If it's a memory leak it's easy to track by setting |
The problem is that, as previously, it's not the same set of unit tests that fail. |
The first error (in To validate I run |
For |
I have also have error popping up for |
OK, I think I've got the culprit: seems to me that the Run the following test function 5000 times with different settings: library(MSnbase)
library(msdata)
f <- msdata::proteomics(full.names = TRUE, pattern = "TMT_Erwinia")
test_apply_non_function <- function(files, readFile = FALSE,
readHeader = FALSE, doGc = FALSE,
backend = "Ramp") {
if (readFile) {
cat("1.")
msdata <- mzR::openMSfile(files, backend = backend)
if (readHeader) fullhd <- mzR::header(msdata)
mzR::close(msdata)
msdata <- NULL
if (doGc) gc()
}
cat("2.")
pdata <- NULL
## Create 'fdata' and 'pdata' objects
if (is.null(pdata)) {
.pd <- data.frame(sampleNames = basename(files))
rownames(.pd) <- .pd$sampleNames
pdata <- new("NAnnotatedDataFrame", data = .pd)
}
cat("3.")
} Running this with: for (i in 1:5000) {
cat(i, "...")
tmp <- test_apply_non_function(f, readFile = FALSE, doGc = FALSE,
backend = "Ramp")
cat("OK\n")
} Works nicely, but for (i in 1:5000) {
cat(i, "...")
tmp <- test_apply_non_function(f, readFile = TRUE, doGc = FALSE,
backend = "Ramp")
cat("OK\n")
} throws the famous for (i in 1:5000) {
cat(i, "...")
tmp <- test_apply_non_function(f, readFile = TRUE, doGc = TRUE,
backend = "Ramp")
cat("OK\n")
} works nicely. This is why I expect that the problem is actually coming from the Switching to the |
Thank you @jotsetung - I agree with you that the problem is in
What do you think? |
@lgatto I agree. I screened a little through the |
Given that PR sneumann/mzR#49 has now been merged, option 2 above seems to be the way to go. The first one that pushes usage of the |
Guess what, using |
Do you think we should consider bringing this up on the Rcpp list? |
I'm trying to do some more tests (to be sure that's not our fault) and will define a neat test case showing the problem. |
OK, these are the results thus far: test_fun <- function(file, backend = "Ramp", doGc = FALSE, newClass = FALSE,
newAdf = FALSE) {
msd <- mzR::openMSfile(file, backend = backend)
mzR::close(msd)
rm(msd)
if (newClass)
nc <- new("dummy", content = "something")
if (newAdf) {
adf <- new("AnnotatedDataFrame", data = data.frame(a = 1:10))
}
if (doGc) gc()
} Running library(mzR)
f <- system.file("microtofq/MM8.mzML", package = "msdata")
for (i in 1:5000) {
if (i %% 200 == 0)
cat(i, "\n")
test_fun(f)
} No problem. Creating a new object with ## Define a dummy class
setClass("dummy",
slots = c(content = "character"),
prototype = prototype(
content = "none"
))
for (i in 1:5000) {
if (i %% 200 == 0)
cat(i, "\n")
test_fun(f, newClass = TRUE)
} All OK. BUT: library(Biobase)
for (i in 1:5000) {
if (i %% 200 == 0)
cat(i, "\n")
test_fun(f, newAdf = TRUE)
}
200
400
600
800
1000
1200
1400
1600
1800
2000
2200
2400
2600
2800
3000
3200
3400
3600
3800
Error in (function (x) (from MSnbase_torture_test.R!15615a0v#9) : attempt to apply non-function Again, calling I'll have a look at the |
Update on the results above: I've tested the function creating different types of objects after the |
Let's celebrate!!! hooray |
too sad, was too early; still getting the error now when using |
What bugs me is that the same test using |
o Add gc() call after data import in readMSData2. o Add gc() call after spectrum/a import in spectrapply.
This should be fixed now - for real - (91255f1). It uses now |
* master: (312 commits) close #153: update low/highMZ checks in validateOnDiskMSnSet suggest microbenchmark and suppress message in benchark vig Add unit test for issue #118 Fix failing tests and example due to r120413 in Biobase Fix for loop that iterates over spectra to work with empty objects Spectra import without need to read mzML header Intermediate fix for issue #151 add unit test for extractMgfSpectrum2Info fix warning in readMgfData if TITLE contains multiple = split MSnExp tests and new [[ error test fix OnDiskMSnExp [[ subsetting - closes issue 152 coding style add gc to readMSData2 - (hopefully) closes #151 coding style use centroided argument in plot.Spectrum.Spectrum example; see issue #150 coding style set mode in calculateFragments example remove expecting warning when peak picking centroided spectrum, not silently returns object fix centoided test in spectrum functions - see issue #150 centroided accessor with na.fail unit test ... From: Laurent <lg390@cam.ac.uk> git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/MSnbase@120585 bc3139a8-67e5-0310-9ffc-ced21a209358
* master: (312 commits) close #153: update low/highMZ checks in validateOnDiskMSnSet suggest microbenchmark and suppress message in benchark vig Add unit test for issue #118 Fix failing tests and example due to r120413 in Biobase Fix for loop that iterates over spectra to work with empty objects Spectra import without need to read mzML header Intermediate fix for issue #151 add unit test for extractMgfSpectrum2Info fix warning in readMgfData if TITLE contains multiple = split MSnExp tests and new [[ error test fix OnDiskMSnExp [[ subsetting - closes issue 152 coding style add gc to readMSData2 - (hopefully) closes #151 coding style use centroided argument in plot.Spectrum.Spectrum example; see issue #150 coding style set mode in calculateFragments example remove expecting warning when peak picking centroided spectrum, not silently returns object fix centoided test in spectrum functions - see issue #150 centroided accessor with na.fail unit test ... From: Laurent <lg390@cam.ac.uk> git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/MSnbase@120585 bc3139a8-67e5-0310-9ffc-ced21a209358
* master: (312 commits) close #153: update low/highMZ checks in validateOnDiskMSnSet suggest microbenchmark and suppress message in benchark vig Add unit test for issue #118 Fix failing tests and example due to r120413 in Biobase Fix for loop that iterates over spectra to work with empty objects Spectra import without need to read mzML header Intermediate fix for issue #151 add unit test for extractMgfSpectrum2Info fix warning in readMgfData if TITLE contains multiple = split MSnExp tests and new [[ error test fix OnDiskMSnExp [[ subsetting - closes issue 152 coding style add gc to readMSData2 - (hopefully) closes #151 coding style use centroided argument in plot.Spectrum.Spectrum example; see issue #150 coding style set mode in calculateFragments example remove expecting warning when peak picking centroided spectrum, not silently returns object fix centoided test in spectrum functions - see issue #150 centroided accessor with na.fail unit test ... From: Laurent <lg390@cam.ac.uk> git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/MSnbase@120585 bc3139a8-67e5-0310-9ffc-ced21a209358
This is a follow up on issue #138. There are still randomly failing unit tests.
The randomly failing test have been observed when running
source("testthat.R")
andR CMD check
(albeit less often with the former). The randomness of the failures could point to memory leaks.The text was updated successfully, but these errors were encountered: