High memory usage in vibe.d application

Anton Fediushin fediushin.anton at yandex.com
Fri Jun 29 11:09:00 UTC 2018


On Friday, 29 June 2018 at 10:31:14 UTC, bauss wrote:
> On Friday, 29 June 2018 at 10:21:24 UTC, Radu wrote:
>> On Friday, 29 June 2018 at 09:44:27 UTC, Anton Fediushin wrote:
>>> Almost forgot, there are two timers which call this function 
>>> for two different streams.
>>>
>>> Value of `metaint` is 16000, which means that only 16KB of 
>>> memory are allocated for the `buffer`, then it reads another 
>>> byte which contains length of the metadata / 16 and then it 
>>> reads the metadata which is 100-200 bytes long.
>>>
>>> This gives us... 16KiB per one nowPlaying() call. Why doesn't 
>>> it free the memory?
>>
>> Maybe use the 
>> https://dlang.org/phobos/std_experimental_allocator_mallocator.html instead of theAllocator as it defaults to GC.
>>
>> Also, why you .idup the array? .array already creates a new 
>> one on the heap.
>
> This.
>
> Which kind of makes the usage of theAllocator useless.

Indeed, because it uses GC by default my `theAllocator.dispose` 
did nothing, which basically made these two samples of code equal.

>
> I was going to suggest using @nogc too, because it would most 
> likely be GC allocated memory that is taking up space.

It is GC's fault for sure, I built my program with profile-gc and 
it allocated a lot there. Question is, why doesn't it free this 
memory?

>
> I run multiple vibe.d applications and I have no issues with 
> memory (Even with GC.)

Me neither, my other vibe.d project uses 7.5MB and that's it.




More information about the Digitalmars-d-learn mailing list