Solved

size of arraylist in bytes

Posted on 2003-12-11
5
441 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 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

630 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