Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

size of arraylist in bytes

Posted on 2003-12-11
5
Medium Priority
?
448 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 1500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

660 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