[PR #8839] [CLOSED] fix: free clip_image_u8 objects in clip_image_preprocess #12793

Closed
opened 2026-04-13 00:09:50 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/8839
Author: @yushihang
Created: 2/5/2025
Status: Closed

Base: mainHead: fix/clip-image-memory-leak


📝 Commits (1)

  • d45875b fix: free clip_image_u8 objects in clip_image_preprocess

📊 Changes

1 file changed (+1 additions, -0 deletions)

View changed files

📝 llama/llama.cpp/examples/llava/clip.cpp (+1 -0)

📄 Description

Fix memory leak in clip_image_preprocess function where clip_image_u8 objects returned by uhd_slice_image were not being freed. Added explicit calls to clip_image_u8_free() after converting each image to clip_image_f32.

The memory leak occurred because:

  • uhd_slice_image allocates multiple clip_image_u8 objects
  • These objects were stored in the returned vector
  • The caller (clip_image_preprocess) didn't free them after use

This commit ensures proper cleanup of all allocated clip_image_u8 objects.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/8839 **Author:** [@yushihang](https://github.com/yushihang) **Created:** 2/5/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/clip-image-memory-leak` --- ### 📝 Commits (1) - [`d45875b`](https://github.com/ollama/ollama/commit/d45875b71da0b6bc74b99c7900f41fef340a4281) fix: free clip_image_u8 objects in clip_image_preprocess ### 📊 Changes **1 file changed** (+1 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `llama/llama.cpp/examples/llava/clip.cpp` (+1 -0) </details> ### 📄 Description Fix memory leak in clip_image_preprocess function where clip_image_u8 objects returned by uhd_slice_image were not being freed. Added explicit calls to clip_image_u8_free() after converting each image to clip_image_f32. The memory leak occurred because: - uhd_slice_image allocates multiple clip_image_u8 objects - These objects were stored in the returned vector - The caller (clip_image_preprocess) didn't free them after use This commit ensures proper cleanup of all allocated clip_image_u8 objects. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 00:09:50 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#12793