Hi Mike,
It is a good suggestion of saving the table to disk, recording the memory usage, then deleting from disk. However a fundamental problem with this approach is that it doesn't take into account the memory overhead of holding a kdb object on memory, so normally you end up with under-estimated result.
My initial thoughts were to define a function to note the used memory before, copy the table to a new tTemp variable, calculate the difference in memory, then delete the temporary variable (tTemp deletes after function execution, so no need to do this step explicitly):
f: { memBefore: .Q.w[][`used] ; tTemp:t; memChange: .Q.w[][`used] - memBefore ; memChange }
f[] returns 6
Unfortunately that isn't a working solution, but does give a little clarity on what kdb+ does when a table is copied. We see little change in the memory usage because instead of storing the copied table in memory, the tTemp simply points to your original table.
One way to force a new instance of the table in memory is to just recreate your original table creation: t:([]a:`p#til 1000000;b:1000000?0 1 2)
f: { memBefore: .Q.w[][`used] ; t2::([]a:`p#til 1000000;b:1000000?0 1 2); memChange: .Q.w[][`used] - memBefore; memChange }
f[] returns 75497568
This requires you to know the original table creation function so that it can be recreated and stored as t2. If you are working with a manipulated table and cannot simply recreate it, then this solution isn't appropriate.
Thanks,
MatthewKDB+ Developer, AquaQ Analytics Ltd
--
You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to personal-kdbpl...@googlegroups.com.
To post to this group, send email to personal...@googlegroups.com.
Visit this group at http://groups.google.com/group/personal-kdbplus.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to personal-kdbplus+unsubscribe@googlegroups.com.
To post to this group, send email to personal-kdbplus@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Kdb+ Personal Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to personal-kdbpl...@googlegroups.com.
To post to this group, send email to personal...@googlegroups.com.
Best,
WooiKent Lee
Financial Software Developer
AQUAQ Analytics
"This email, its contents and any files attached are a confidential communication and are intended only for the named addressees indicated in the message.
If you are not the named addressee or if you have received this email in error, you may not, without the consent of AquaQ Analytics, copy, use or rely on any information or attachments in any way. Please notify the sender by return email and delete it from your email system.
Unless separately agreed, AquaQ Analytics does not accept any responsibility for the accuracy or completeness of the contents of this email or its attachments. Please note that any views, opinion or advice contained in this communication are those of the sending individual and not those of AquaQ Analytics and AquaQ Analytics shall have no liability whatsoever in relation to this communication (or its content) unless separately agreed"