Skip to content

Conversation

Copy link

Copilot AI commented Dec 24, 2025

Large numpy arrays created during sonar image export were not being explicitly freed, causing memory accumulation during batch processing.

Changes

  • class_sonObj.py and class_sonObj_nadirgaptest.py: Added del and gc.collect() after imsave() calls in:

    • _writeTiles(): Cleanup temporary data array
    • _writeTilesPlot(): Cleanup norm_data, colored_data, and data arrays
    • _exportMovWin(): Cleanup a_img, b_img, and movWin arrays after processing each tile type
  • class_portstarObj.py: Added gc.collect() after existing del statements following debug image saves

Example

def _writeTiles(self, k, imgOutPrefix, tileFile='.jpg', colormap=False):
    data = self.sonDat.astype('uint8')
    # ... prepare output directory and filename ...
    imsave(os.path.join(outDir, filename), data, check_contrast=False)
    
    # Clean up temporary data array to free memory
    del data
    gc.collect()
    
    return

The gc module is already imported via from pingmapper.funcs_common import *.

Original prompt

Can you help with room drain and image generation


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: CameronBodine <54146655+CameronBodine@users.noreply.github.com>
Copilot AI changed the title [WIP] Add room drain and image generation features Add explicit memory cleanup after image generation operations Dec 24, 2025
Copilot AI requested a review from CameronBodine December 24, 2025 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants