I’m using Marshal.dump to serialize an array of objects, I need to get the size (in KB) of the returned value. Any ideas how to do that?
I’m using Marshal.dump to serialize an array of objects, I need to get the
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Since the output of
Marshal.dumpis a string, you can just ask for the length of that. The safest way to do this is to ask forbytesize:The
bytesizemethod always returns the length of a string in bytes, whereaslengthreturns the length of the string in characters. The two values can differ if you use a multi-byte encoding method like UTF-8.