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 4586128
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:35:41+00:00 2026-05-21T21:35:41+00:00

I have one very large (10mb) csv file. I parsed it and put it

  • 0

I have one very large (10mb) csv file. I parsed it and put it into memory using a generic list.

I created a class to represent each line. This class has only several fields (data type ip-address, string).

I thoguht that since the file is only 10 megabytes I could expect a similar size in-memory.

I was quite surprised when I found out that the method that is creating the list is allocating 300 mb and not freeing it up.

Is this normal, and what can be causing this.

Note that the csv file has many lines (100 000 +) this could be a factor.


Namespace Geo
Public Class CountryMarker
Public StartAddress As IPAddress
Public EndAddress As IPAddress
Public Country As String
Public CountryCode As String
End Class

Public Class Markers
    Private Const DatabasePath = "~/App_Data/ip.csv" '10 MB file
    Public Shared List As List(Of CountryMarker) = LoadData()

    Shared Function LoadData() As List(Of CountryMarker)
        Dim Markers As New List(Of CountryMarker)

        Using Stream = New IO.FileStream(Hosting.HostingEnvironment.MapPath(DatabasePath), FileMode.Open)
            Dim Reader = New StreamReader(Stream)

            Do While Reader.Peek > -1
                Dim Line = Reader.ReadLine()
                Dim Values = Line.Split(",").Select(Function(i) i.Replace("""", ""))

                Markers.Add(New CountryMarker With {.Country = Values(5), .CountryCode = Values(4), .StartAddress = IPAddress.Parse(Values(0)), .EndAddress = IPAddress.Parse(Values(1))})
            Loop
        End Using

        Return Markers
    End Function
End Class

End Namespace

  • 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-05-21T21:35:42+00:00Added an answer on May 21, 2026 at 9:35 pm

    First, if the file is ASCII text or UTF-8 with predominately Western European characters (like English), then the in-memory size of the text will be at least double the file’s size on disk. .NET stores strings as 16-bit Unicode values. So “A”, for example, which takes one byte in a text file, requires two bytes in memory.

    Each class instance that you create is going to require at least 24 bytes (16 bytes of allocation, plus 8 bytes for the reference.) If your file is 100,000 lines, that’s 2.4 megabytes, minimum. In addition, every string that you allocate will require 24 bytes, plus whatever is required for the string. Things add up quick.

    (Note that my 24 bytes number is for a 64-bit system. It’s 16 bytes per allocation in the 32-bit runtime.)

    As others have commented, it’s impossible to give you any more detail unless you post some code, including your class definition.

    As to not freeing up any memory: that’s kind of difficult to prove. Maybe the garbage collector just hasn’t gotten around to doing a collection yet. If it sees no memory pressure (i.e. there’s plenty of memory available and no other process is begging for memory), the GC might decide it doesn’t need to collect yet.

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

Sidebar

Related Questions

I have a very large file 100Mb+ where all the content is on one
I have two arrays, one is very large (more than million entries) and other
I have to migrate a very large dataset from one system to another. One
I have UITableView with very large cells with lots of content (more than one
I am modifying a wordpress theme completely, and have run into one very simple
One thing I have continually found very confusing about using an object database like
I have a very simple scenario, using NHibernate: one abstract base class animal; two
I have a very large database with about 120 Million records in one table.I
I have two very large enterprise tables in an Oracle 10g database. One table
I have a very large List[A] and a function f: List[A] => List[B] .

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.