473,326 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Slowness in Serialize

I've got an ArrayList of objects that I'd like to save/retrieve as quickly
as possible. Each item in the arraylist is an object with about 50
variable-length strings; many zero-length, some about 80 chars or so,
if that matters.

I figured I'd set the [Serializable] attribute on the object and on the
ArrayList and use standard Serialize() functions. This is just incredibly
slow. Is that normal? Any other recommended approach?

The function itself is listed below, but I think it's boilerplate:

private bool Serialize(string Filename) {
FileStream binfs;
IFormatter ifmtr = new BinaryFormatter();
bool retval = true;
binfs = new FileStream(
Filename, // expect full path and file name
FileMode.Create,
FileAccess.Write,
FileShare.None);
try {
ifmtr.Serialize(binfs, this);
binfs.Close();
} catch (SerializationException ex) {
// MessageBox.Show(ex.ToString());
retval = false;
}
return retval;
}
Nov 16 '05 #1
6 1579
Usually the *first time is really slow cause the assembly is loaded. The
next times should be faster. Serialization is still going to be a bit slow.
I think they made some improvements in Whidbey.

--
William Stacey, MVP
http://mvp.support.microsoft.com

"_BNC" <_B**@nospam.net> wrote in message
news:q0********************************@4ax.com...
I've got an ArrayList of objects that I'd like to save/retrieve as quickly
as possible. Each item in the arraylist is an object with about 50
variable-length strings; many zero-length, some about 80 chars or so,
if that matters.

I figured I'd set the [Serializable] attribute on the object and on the
ArrayList and use standard Serialize() functions. This is just incredibly
slow. Is that normal? Any other recommended approach?

The function itself is listed below, but I think it's boilerplate:

private bool Serialize(string Filename) {
FileStream binfs;
IFormatter ifmtr = new BinaryFormatter();
bool retval = true;
binfs = new FileStream(
Filename, // expect full path and file name
FileMode.Create,
FileAccess.Write,
FileShare.None);
try {
ifmtr.Serialize(binfs, this);
binfs.Close();
} catch (SerializationException ex) {
// MessageBox.Show(ex.ToString());
retval = false;
}
return retval;
}


Nov 16 '05 #2
Hi,

By default , Serailizable attribute does all the neccessary thing but i
would suggest to control the process of serialization, you can implement the
ISerializable interface and get your things done fast.

Pls go through my this article, which i hope wil help you
http://www.codeproject.com/Purgatory...ion_in_NET.asp

regards
Nishith

"_BNC" wrote:
I've got an ArrayList of objects that I'd like to save/retrieve as quickly
as possible. Each item in the arraylist is an object with about 50
variable-length strings; many zero-length, some about 80 chars or so,
if that matters.

I figured I'd set the [Serializable] attribute on the object and on the
ArrayList and use standard Serialize() functions. This is just incredibly
slow. Is that normal? Any other recommended approach?

The function itself is listed below, but I think it's boilerplate:

private bool Serialize(string Filename) {
FileStream binfs;
IFormatter ifmtr = new BinaryFormatter();
bool retval = true;
binfs = new FileStream(
Filename, // expect full path and file name
FileMode.Create,
FileAccess.Write,
FileShare.None);
try {
ifmtr.Serialize(binfs, this);
binfs.Close();
} catch (SerializationException ex) {
// MessageBox.Show(ex.ToString());
retval = false;
}
return retval;
}

Nov 16 '05 #3
On Mon, 8 Nov 2004 20:04:13 -0500, "William Stacey [MVP]"
<st***********@mvps.org> wrote:
Usually the *first time is really slow cause the assembly is loaded. The
next times should be faster. Serialization is still going to be a bit slow.
I think they made some improvements in Whidbey.


I hope so. I was trying to replace a somewhat slow XML parser (the
original file was a proprietary XML format). I was shocked to find out
that the binary serialize was several times slower at storing the info
than the XML parser. That doesn't make much sense.

Nov 16 '05 #4
On Mon, 8 Nov 2004 20:04:13 -0500, "William Stacey [MVP]"
<st***********@mvps.org> wrote:
Usually the *first time is really slow cause the assembly is loaded. The
next times should be faster. Serialization is still going to be a bit slow.
I think they made some improvements in Whidbey.


I hope so. I was trying to replace a somewhat slow XML parser (the
original file was a proprietary XML format). I was shocked to find out
that the binary serialize was several times slower at storing the info
than the XML parser. That doesn't make much sense.

Nov 16 '05 #5
No it doesn't. I wonder if something else is going on?

--
William Stacey, MVP
http://mvp.support.microsoft.com

"_BNC" <_B**@nospam.net> wrote in message
news:85********************************@4ax.com...
On Mon, 8 Nov 2004 20:04:13 -0500, "William Stacey [MVP]"
<st***********@mvps.org> wrote:
Usually the *first time is really slow cause the assembly is loaded. The
next times should be faster. Serialization is still going to be a bit slow.I think they made some improvements in Whidbey.


I hope so. I was trying to replace a somewhat slow XML parser (the
original file was a proprietary XML format). I was shocked to find out
that the binary serialize was several times slower at storing the info
than the XML parser. That doesn't make much sense.


Nov 16 '05 #6
No it doesn't. I wonder if something else is going on?

--
William Stacey, MVP
http://mvp.support.microsoft.com

"_BNC" <_B**@nospam.net> wrote in message
news:85********************************@4ax.com...
On Mon, 8 Nov 2004 20:04:13 -0500, "William Stacey [MVP]"
<st***********@mvps.org> wrote:
Usually the *first time is really slow cause the assembly is loaded. The
next times should be faster. Serialization is still going to be a bit slow.I think they made some improvements in Whidbey.


I hope so. I was trying to replace a somewhat slow XML parser (the
original file was a proprietary XML format). I was shocked to find out
that the binary serialize was several times slower at storing the info
than the XML parser. That doesn't make much sense.


Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: _BNC | last post by:
I've got an ArrayList of objects that I'd like to save/retrieve as quickly as possible. Each item in the arraylist is an object with about 50 variable-length strings; many zero-length, some about...
0
by: Nicole | last post by:
Has anyone else experienced a dramatic slow down of performance with their ADP's after upgrading to Service Pack 2 or above? The slowness occurs exclusively when pulling data from SQL Server in...
7
by: Mike Nygard | last post by:
I'm experiencing extremely slow response times in design mode of my forms since moving to Access 2003. Simply dragging a button to a different position on the form takes 30 seconds or more. The...
5
by: David Sworder | last post by:
Hi, I've created a UserControl-derived class called MyUserControl that is able to persist and subsequently reload its state. It exposes two methods as follows: public void Serialize(Stream...
10
by: Dan | last post by:
All I Am Attempting To Serialize An Object To An XML File. Here Is The Code For That public string SaveNewSurvey( MutualSurveyObject mso_TempObject, int i_JobID ) { string s_RootFileName;...
1
by: js | last post by:
Does anybody knows how to solve the problem? I added attribute to the following classes in Microsoft.Practices.EnterpriseLibrary.Data namespace, but I still get the error. Thanks. ...
8
by: cd~ | last post by:
I can provide a test app, the news server won't allow me to post the files because they are too large (93KB and 1.2KB) I downloaded the ESRI ArcXml schema and generated the classes from the...
1
by: Tim | last post by:
Could anyone tell me what this means and how do I correct it. Any suggestions? Thanks! Tim Richardson IT Developer and Consultant www.paladin3d.com Unable to serialize the session state. In...
4
by: =?Utf-8?B?Qnlyb24=?= | last post by:
When I try to serialize an instance of the LocationCell below (note Building field) I get an error in the reflection attempt. If I remove the _Building field it serializes fine. I tried renaming...
9
by: Gillard | last post by:
i get an exeption and i do not know what else to do to continue Dim sdf As New SaveFileDialog With sdf .AddExtension = True .DefaultExt = ".record" .FileName = Now.ToLongDateString .Filter =...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.