Commit 773f29b3 authored by Mikaël Salson's avatar Mikaël Salson

core/windows, vidjil.cpp: Delete WindowsStorage while it is exported to JSON

Fixes #3395
parent 5b89dabd
Pipeline #35293 passed with stages
in 42 minutes and 24 seconds
......@@ -266,12 +266,12 @@ void WindowsStorage::clearSequences(){
seqs_by_window.clear();
}
json WindowsStorage::sortedWindowsToJson(map <junction, json> json_data_segment, int max_json_output) {
json WindowsStorage::sortedWindowsToJson(map <junction, json> json_data_segment, int max_json_output, bool delete_all) {
json windowsArray;
int top = 1;
for (list<pair <junction, size_t> >::const_iterator it = sort_all_windows.begin();
it != sort_all_windows.end(); ++it)
it != sort_all_windows.end(); )
{
json windowsList;
......@@ -295,6 +295,13 @@ json WindowsStorage::sortedWindowsToJson(map <junction, json> json_data_segment,
windowsArray.push_back(windowsList);
if (delete_all) {
germline_by_window.erase(it->first);
status_by_window.erase(it->first);
it = sort_all_windows.erase(it);
} else {
it++;
}
if (top == max_json_output + 1)
break ;
}
......
......@@ -218,8 +218,13 @@ class WindowsStorage {
* @max_json_output: maximal number of windows to output (<= 0: no limit)
*/
ostream &printSortedWindows(ostream &os);
json sortedWindowsToJson(map<junction, json> json_data_segment, int max_json_output);
/**
* @param delete_all: Delete the objects while they are inserted into the JSON. This prevents the memory
* from continously increasing (see #2120, #3387)
* @return a JSON object containing all the information
*/
json sortedWindowsToJson(map<junction, json> json_data_segment, int max_json_output, bool delete_all=false);
/**
* Clear the seqs_by_window map.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment