mudler/LocalAI · error
Failed to allocate memory for resized reference image\n
Error message
Failed to allocate memory for resized reference image\n
What it means
Allocation for the resized reference image buffer failed. Guard: validate image dimensions are within sane bounds before allocating; on failure abort with an out-of-memory error instead of dereferencing null.
Source
Thrown at backend/go/stablediffusion-ggml/cpp/gosd.cpp:960
int ref_height = 0;
uint8_t* ref_image_buffer = stbi_load(ref_images[i], &ref_width, &ref_height, &c, 3);
if (ref_image_buffer == NULL) {
fprintf(stderr, "Failed to load reference image from '%s'\n", ref_images[i]);
continue;
}
if (c < 3) {
fprintf(stderr, "Reference image must have at least 3 channels, got %d\n", c);
free(ref_image_buffer);
continue;
}
// Resize reference image if dimensions don't match
if (ref_width != width || ref_height != height) {
fprintf(stderr, "Resizing reference image from %dx%d to %dx%d\n", ref_width, ref_height, width, height);
uint8_t* resized_ref_buffer = (uint8_t*)malloc(height * width * 3);
if (resized_ref_buffer == NULL) {
fprintf(stderr, "Failed to allocate memory for resized reference image\n");
free(ref_image_buffer);
continue;
}
stbir_resize(ref_image_buffer, ref_width, ref_height, 0,
resized_ref_buffer, width, height, 0, STBIR_TYPE_UINT8,
3, STBIR_ALPHA_CHANNEL_NONE, 0,
STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP,
STBIR_FILTER_BOX, STBIR_FILTER_BOX,
STBIR_COLORSPACE_SRGB, nullptr);
free(ref_image_buffer);
ref_image_buffer = resized_ref_buffer;
}
ref_image_buffers.push_back(ref_image_buffer);
ref_images_vec.push_back({(uint32_t)width, (uint32_t)height, 3, ref_image_buffer});
}View on GitHub (pinned to 44413a9d06)
Solutions
- Free memory or reduce reference image dimensions so the resize allocation succeeds.
- Check overall memory usage of the backend process.
When it happens
Trigger: Thrown at backend/go/stablediffusion-ggml/cpp/gosd.cpp:960 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15).
Data as JSON: /api/errors/6b1b2ece145f7d03.
Report an issue: GitHub.