Open
Description
Describe the bug
When sending a byte array to 'GetChatMessageContentsAsync' specifically targeting OpenAi Gpt 4.1. I can see the memory usage spike by 80x the original byte arrays size.
To Reproduce
Steps to reproduce the behavior:
- Send a byte array chat completion to GPT 4.1
- Monitor memory usage
- See it spike by 80x the byte array size.
Expected behavior
I would expect some memory usage to increase, however I do not expect a 80x increase, that seems a bit much?
Screenshots
Here is me passing an image that is around 5MB, prior to uploading (right up to the semantic kernel line) memory usage was around 35MB. After calling the semantic kernel code, memory shoots up to 385MB.
My code... I run my calls in parallel, with there being 2 parallel calls executing at the moment. I have also tried to make them sequential with the same result
Platform
- Language: C#
- Source: Microsoft.SemanticKernel 1.49.0 - OpenAI 2.2.0-beta.4
- AI model: gpt-4.1 (version:2025-04-14)
- IDE: Rider
- OS: Windows/Linux