Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pingmapper/class_portstarObj.py
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,9 @@ def _depthZheng(self,i,tileFile):
del maxDepths, minDepths, avgDepths, Wp, portDepPixCrop, starDepPixCrop
del portDepPix, starDepPix
del model, self.bedpickModel ######## Not sure about this one...

# Force garbage collection to free memory
gc.collect()

# return #self
return portDepPixFinal, starDepPixFinal, i
Expand Down
16 changes: 15 additions & 1 deletion pingmapper/class_sonObj.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,10 @@ def _writeTiles(self,
projName = os.path.split(self.projDir)[-1] #to append project name to filename
imsave(os.path.join(outDir, projName+'_'+imgOutPrefix+'_'+channel+'_'+addZero+str(k)+tileFile), data, check_contrast=False)

# Clean up temporary data array to free memory
del data
gc.collect()

return

def _writeTilesPlot(self,
Expand Down Expand Up @@ -1253,6 +1257,9 @@ def _writeTilesPlot(self,
colored_data = plt.cm.get_cmap(self.sonogram_colorMap)(norm_data)
colored_data = (colored_data[:, :, :3] * 255).astype('uint8')
data = colored_data

# Clean up temporary arrays
del norm_data, colored_data

# imsave(outfile, data)

Expand All @@ -1262,7 +1269,10 @@ def _writeTilesPlot(self,
# imsave(outfile, data, check_contrast=False)

imsave(outfile, data, check_contrast=False)


# Clean up temporary data array to free memory
del data
gc.collect()

return

Expand Down Expand Up @@ -1549,6 +1559,10 @@ def resize_to_pingMax(img, cropMax):

win += to_stride

# Clean up large arrays to free memory
del a_img, b_img, movWin
gc.collect()

return


Expand Down
16 changes: 15 additions & 1 deletion pingmapper/class_sonObj_nadirgaptest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,10 @@ def _writeTiles(self,
projName = os.path.split(self.projDir)[-1] #to append project name to filename
imsave(os.path.join(outDir, projName+'_'+imgOutPrefix+'_'+channel+'_'+addZero+str(k)+tileFile), data, check_contrast=False)

# Clean up temporary data array to free memory
del data
gc.collect()

return

def _writeTilesPlot(self,
Expand Down Expand Up @@ -1197,6 +1201,9 @@ def _writeTilesPlot(self,
colored_data = plt.cm.get_cmap(self.sonogram_colorMap)(norm_data)
colored_data = (colored_data[:, :, :3] * 255).astype('uint8')
data = colored_data

# Clean up temporary arrays
del norm_data, colored_data

# imsave(outfile, data)

Expand All @@ -1206,7 +1213,10 @@ def _writeTilesPlot(self,
# imsave(outfile, data, check_contrast=False)

imsave(outfile, data, check_contrast=False)


# Clean up temporary data array to free memory
del data
gc.collect()

return

Expand Down Expand Up @@ -1460,6 +1470,10 @@ def resize_to_pingMax(img, cropMax):

win += to_stride

# Clean up large arrays to free memory
del a_img, b_img, movWin
gc.collect()

return


Expand Down