1

I have a C# program that populates a dictionary with 4Million Guids at startup. I keep getting an Exception of type 'System.OutOfMemoryException' error at this point.

Example:

using (reportingconn)
{
    var initialrowkeys = reportingconn.Query("select rowkey from table”);
}

Can anyone give me some ideas how best to retrieve large amounts data from SQL into a dictionary?

7
  • 3
    Do you really need all 4 million at once? are you looking for a specific one? Commented Mar 29, 2013 at 19:05
  • 2
    Why do you need to populate 4 million guids at startup? That is the problem here. Commented Mar 29, 2013 at 19:05
  • 4
    I love this question - classic case of something grizzled old programmers would never ask and young programmers rarely have to consider (stream your data, small RAM). Commented Mar 29, 2013 at 19:06
  • @Brad I need to use those guids to retrieve data from Azure table storage n a loop. I do not want to keep hitting the database every-time. Commented Mar 29, 2013 at 19:10
  • 1
    Databases are meant to store large amounts of data and be able to handle large numbers of queries. I'd be more worried about a query returning millions of results than hitting the database for data on-demand. Commented Mar 29, 2013 at 19:18

2 Answers 2

5

Use SqlDataReader() this will read row by row, instead of SqlDataAdapter.Fill.

Sign up to request clarification or add additional context in comments.

Comments

0

It seems like there is a 2GB memory limitation on C# data dictionary. A programmer friend told me to change my console application from 32 bit to 64 bit to prevent that limitaion. That seems to have resolved my problem.

1 Comment

I would guess the limit is more like 2 GB of contiguous addressable memory. Some Good reading

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.