Run following code on a page or in the developer shell:
for { set n 0 } { $n<10000 } { incr n } {
set setid [ns_set create]
ns_set put $setid key [string repeat "dummy data" 500]
}
During runtime the system will create 10000 'ns_set' objects and memory consumption of the process will increase by approximately 80mb.
But at the end of the request, the memory is not freed. Instead it is reused, because if you run the code block again, the memory consumption keeps constant. If you run the code block a third time and change the for condition to $n<20000 then the memory allocation will be constant for the first 10000 iterations and increasing again for iteration 10001 to 20000.
Is this kind of memory pool an intended behavior? Will the memory be freed later?
Beside that, shouldn’t functions which are use ns_set's call 'ns_set free'? The function db_0or1row doesn't free the ns_set. This could result in an out of memory problem if you are calling the function within a request often enough.