Solved

size of arraylist in bytes

Posted on 2003-12-11
5
415 Views
Last Modified: 2011-10-03
hi

is there a way to find out the size (in bytes) of an arraylist and all of its contents?

(i need to know the file-size before I serialize the arraylist.)

thanks!
0
Comment
Question by:windsofchange
5 Comments
 
LVL 18

Expert Comment

by:testn
ID: 9924259
Why don't you serialize it first and then measure the size...
0
 
LVL 7

Expert Comment

by:TransBind
ID: 9924943
Use the FileInfo class:
FileInfo info = new FileInfo(path);
long fileSize = info.Length;
0
 

Expert Comment

by:sentosa_gani
ID: 9925161
is sizeof(arraylist) any help?
0
 
LVL 20

Accepted Solution

by:
TheAvenger earned 500 total points
ID: 9926580
There is no way to get the size of non value types. Maybe you can try to calculate it yourself based on the knowledge how many and what objects are in the ArrayList and also by seeing how much bytes the ArrayList data takes. So just make some tests like serializing the ArrayList empty, then with 1, 2 objects and you will figure it out. If you use objects like strings, I suppose it will be harder, But if you store objects like int, it will work.
0
 

Author Comment

by:windsofchange
ID: 9927599
that's what i feared. i actually now make some kind of estimation.
thanks!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question