# The Purge...



## Rasoul Morteza (Sep 8, 2020)

No I'm not talking about the movie.

Could someone please confirm that purging samples doesn't affect the actual amount of memory in use unless you entirely restart the host?(!)

Purging samples, deactivating the track and even deleting the damn track doesn't release/flush the memory initially taken by the patch. Is this really normal? I've been scratching my head for hours trying to figure out why in the world do I have to restart Cubase entirely to release the memory taken up by Kontakt once it was loaded... and this is irrespective of the loaded patch. It's just Kontakt.

If you delete the instrument track, shouldn't the memory be released?

Cheers


----------



## purple (Sep 8, 2020)

That's odd. It should be releasing the memory when you purge or "update sample pool". If not when you purge, then at least when that track is closed. Does it happen to all kontakt instruments? Or a specific one? Are there perhaps additional copies of it running that are using the same ram footprint?


----------



## d.healey (Sep 9, 2020)

How are you monitoring memory usage?


----------



## Rasoul Morteza (Sep 9, 2020)

purple said:


> That's odd. It should be releasing the memory when you purge or "update sample pool". If not when you purge, then at least when that track is closed. Does it happen to all kontakt instruments? Or a specific one? Are there perhaps additional copies of it running that are using the same ram footprint?


It happens on all.


d.healey said:


> How are you monitoring memory usage?


Memory displayed in the task manager's details tab (private working set), associated with Cubase.exe


----------



## d.healey (Sep 9, 2020)

Rasoul Morteza said:


> Memory displayed in the task manager's details tab (private working set), associated with Cubase.exe


Does Cubase hold onto (reserve) memory it's previously used and release it as more RAM is required? Does Cubase have it's own memory monitor?


----------



## Rasoul Morteza (Sep 9, 2020)

d.healey said:


> Does Cubase hold onto (reserve) memory it's previously used and release it as more RAM is required? Does Cubase have it's own memory monitor?


This appears to be my problem: https://www.steinberg.net/forums/viewtopic.php?f=240&t=85810

_The allocation of RAM always happens through the OS. When I VST instrument is loaded, it is the VST instrument that is "asking RAM" through Nuendo, to the OS. When the VST instrument is unloaded it "releases" the used RAM. Since the VST instrument has asked for RAM through Nuendo, this RAM however is still "held" by Nuendo. Nuendo does want to release that RAM, but can't because the OS won't take orders from Nuendo. (Remember it was the VST intrument that has asked the RAM, although through Nuendo) _

I tried this in FL Studio and I get the same thing. Could you, and anybody on Cubase, just load a heavy Kontakt patch (a few gigs) and see if the memory is properly released if the track is purged/deactivated/deleted, please? It is easy 

And no, Cubase has no memory meter.

Cheers


----------



## Rasoul Morteza (Sep 9, 2020)

@d.healey Ah how didn't I see this earlier... Windows is just caching previously loaded memory (aka Standby memory). Since I have to work on a template later tonight, I'll post here about whether Windows starts gradually releasing the memory once the count goes high enough. I'll have to look into how Windows manages the cache amount. Although this might sound like an explanation, it isn't an optimal scenario however.


----------



## RonOrchComp (Sep 9, 2020)

_When the VST instrument is unloaded it "releases" the used RAM. Since the VST instrument has asked for RAM through Nuendo, this RAM however is still "held" by Nuendo. _ 

That seems to be a contradictory statement no? I can confirm that the RAM is in fact released from Kontakt AND Cubase when patxhes are unloaded. Using Windows7 64 bit here


----------



## Rasoul Morteza (Sep 9, 2020)

RonOrchComp said:


> _When the VST instrument is unloaded it "releases" the used RAM. Since the VST instrument has asked for RAM through Nuendo, this RAM however is still "held" by Nuendo. _
> 
> That seems to be a contradictory statement no? I can confirm that the RAM is in fact released from Kontakt AND Cubase when patxhes are unloaded. Using Windows7 64 bit here


Well not in my case... but then again I'll have to test later tonight if Windows starts releasing the loaded cache once more memory is requested by other processes.


----------



## Rasoul Morteza (Sep 9, 2020)

Ok so I did the experiment:

Windows indeed releases memory once it is needed, basically I loaded one instance of Kontakt taking 50GB of memory, then disabled it. None of the memory was released at that point, but I added some extra instances of Play and Kontakt and loaded them with new sets of instruments taking 40+GB of memory.

I was monitoring the Memory tab and obviously once the memory reached around 60GB it actually started releasing itself free for the new allocations.

There are two downsides however (and in regard to my system):
1. You can't switch between projects, apparently this type of memory management only works inside a single session. So you would have to completely restart your host if you were to load, let's say a project taking 50GB of memory after a project which itself took 50GB of memory. When I did this it literally crashed my system due to insufficient memory (even though all tracks in the initial project were deleted).

2. It is quite hard to really know when you're running out of memory, since what you see in task manager doesn't say shit. Of course you could have a good estimate by seeing how much memory is in use and how much is cached and how much of it is modified, but I'm not supposed to be doing this...

I still wonder if I'm the only person who's OS has decided to optimize memory that way. Could anyone on Win10 do a small test? I'm sure some peeps with their 2000 track templates must have saw something similar...no?

Edit: This seems to be a Kontakt issue only...

Cheers


----------



## philthevoid (Dec 5, 2020)

You are not alone. I've been seeing this behaviour on my Win10 system. It is a Kontakt-only issue. You can test by only running Kontakt as a standalone (no DAW or anything else opened).

1-Open Task Manager on the Process tab and monitor Kontakt RAM usage.
2-Load any VST in Kontakt, ideally one that uses over 1GB of RAM to make this more obvious.
3-Once it's done loading, either use the purge all function or simply unload that VST from Kontakt.
4-Notice that the RAM usage after unloading the instrument (or purging it) has not changed one bit.

Annoying.

EDIT:
Found *this other thread*. Started happening in Kontakt 6.4 apparently?


----------



## EvilDragon (Dec 7, 2020)

This is already discussed in the sticky thread about Kontakt 6 updates and in another thread. Known issue and tracked.


----------

