Skip to content

Seemingly random crashes with amp_drift_corr and convert_measurement loops #1

@sginot

Description

@sginot

Hi Peter,

I was unable to reproduce the error I got in the first run, but had a few more crashes.
It seems to be related to memory usage indeed, as memory use by RStudio keeps on increasing while the loop runs (see screenshots below).

Adding gc() within the loop seemed to help, athough the task manager still shows memory use increasing.

Here is the code run on the raw data (in blanke-nas-1, under Public/Simon/RAW_Data_Cut):

library(forceR)
library(magrittr)
library(dplyr)
library(stringr)
library(purrr)
library(ggplot2)
library(readr)

raw_fold <- "../RAW_Data_Cut"

files <- file.path(raw_fold, list.files(raw_fold, pattern = ".dat"))

for (i in 1:length(files)) {
  convert_measurement(file = files[i], path.data = "./converted_files/")
  gc(verbose = F)
} #Loop crashes R sometimes

convert_fold <- "./converted_files"

con_files <- file.path(convert_fold, list.files(convert_fold))

ampdriftcorr_folder <- "./ampdriftcorr"

for(i in 1:length(con_files)){
  filename <- con_files[i]
  print(filename)
  print(i)
  amp_drift_corr(filename = filename,
                 tau = 9400,
                 res.reduction = 10,
                 plot.to.screen = FALSE,
                 write.data = TRUE,
                 write.PDFs = TRUE,
                 write.logs = TRUE,
                 output.folder = ampdriftcorr_folder,
                 show.progress = FALSE)
  gc()
  print("***********")
} #Loop here also crashes

FroceRcrash
ForceRrun
ForceRrun3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions