Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7774949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:30:25+00:00 2026-06-01T17:30:25+00:00

Following my recent issues with large object heap fragmentation , I’ve revisited some of

  • 0

Following my recent issues with large object heap fragmentation, I’ve revisited some of my serializable classes. I frequently do some Xml serialization and serialize/deserialize objects containing large byte arrays.

In general I just use SerializableAttribute and do not bother about serialization details until I really need some special behaviour. Then I switch to IXmlSerializable interface and write my own serialization/deserialization code.

When manually serializing byte arrays to Xml, I prefer XmlWriter.WriteBase64(byte[] buffer, int index, int count) and XmlReader.ReadElementContentAsBase64(byte[] buffer, int index, int count) methods. This allows me to write data in chunks – very convenient.

But what happens when I just use the SerializableAttribute? Does the automatic serialization mechanism inside .NET framework writes data in chunks (like I do manually) or does it just kill large object heap by creating enormously large strings to hold whole of my byte array serialized with base64? Is the serializer efficient, or should I write my own serialization code to make sure the data is written without unnecessary overhead?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:30:26+00:00Added an answer on June 1, 2026 at 5:30 pm

    Some quick spelunking into the System.Xml.Serialization.XmlSerializer (and XmlSerializationWriter, and System.Xml.Base64Encoder) using Reflector shows that base64 byte arrays are chunked as they are converted.

    “Is the serializer efficient, or should I write my own serialization code to make sure the data is written without unnecessary overhead?”

    “Efficient” is not a binary condition; it is a continuum. Your real question is “Is it efficient enough for what I need?”, and the answer to that is dependent on what you need. Most likely you just need to run some tests between the XmlSerializer and your custom code and see which performs better along the performance dimensions that are most important to you.

    P.S. XmlSerializer does not use the SerializableAttribute; it simply serializes all public read/write properties. Only the Xml*Attributes in System.Xml.Serialization affect the XmlSerializer (along with IXmlSerializable of course).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following on from my recent question on Large, Complex Objects as a Web Service
Following on from my recent question regarding parsing XML files in Java I have
Following recent hardware problems, I attempted to switch a couple of our websites to
I recently received a downvote for using the following in a recent answer :
A recent post by John Gruber notes that the following legalese: 3.3.1 — Applications
Consider the following stacktrace: In [3]: f.clean() --------------------------------------------------------------------------- AttributeError Traceback (most recent call last)
Using the following query and results, I'm looking for the most recent entry where
Which of the following is faster, or are they equivalent? (grabbing recent most records
I am getting a warning in eclipse (the most recent version) for the following
Some time ago declarations like the following were defined by poor performance: var a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.