Questions tagged [large-object-heap]

The Large Object Heap (LOH) is a special type of managed heap for the automatic memory management in .NET Framework.

The Large Object Heap (LOH) is intended for storing large objects. The large objects is an object, which size is 85000 bytes or more. These features are most significant, when working with large objects and LOH:

  • Large objects are always considered part of generation 2.
  • Large objects are never compacted.
92 questions
9
votes
2 answers

Memory usage serializing chunked byte arrays with Protobuf-net

In our application we have some data structures which amongst other things contain a chunked list of bytes (currently exposed as a List). We chunk bytes up because if we allow the byte arrays to be put on the large object heap then over…
James Thurley
  • 2,650
  • 26
  • 38
8
votes
1 answer

Large unexplained memory in the memory dump of a .NET process

I can't explain most of the memory used by a C# process. The total memory is 10 GB, but the total reachable and unreachable objects altogether total 2.5 GB. I wonder what these 7.5 GB could be? I'm looking for the most likely explanations or a…
Benoit Sanchez
  • 681
  • 6
  • 21
8
votes
6 answers

Large Object Heap fragmentation: CLR has any solution to it?

If you application is such that it has to do lot of allocation/de-allocation of large size objects (>85000 Bytes), its eventually will cause memory fragmentation and you application will throw an Out of memory exception. Is there any solution to…
palm snow
  • 2,392
  • 4
  • 29
  • 49
7
votes
3 answers

Large String in Large Object Heap causes issues - but in any case it has to end up as a String

I am following up from this question here The problem I have is that I have some large objects coming from an MSMQ mainly Strings. I have narrowed down my memory problems to these objects being created in the Large Object Heap (LOH) and therefore…
Yannis
  • 6,047
  • 5
  • 43
  • 62
7
votes
1 answer

Processing big strings, Is this Large Object Heap Fragmentation?

I have a .NET 3.5 Application A function is running a million times It's doing search & replace & regex operations in 1MB+ strings (different sized strings) When I profile the application I can confirm these strings are stored in LOH but also they…
dr. evil
  • 26,944
  • 33
  • 131
  • 201
7
votes
1 answer

Reduce the multiple copies of the same object in the Large Object Heap

I am trying to upload the bytes of a large file (around 30MB) with the HTTPWebRequest to some server. The problem is that since the size of bytes is more than 85000, it is getting stored in the LargeObjectHeap(LOH). The problem is that my code is…
Piyush
  • 830
  • 8
  • 19
6
votes
3 answers

caching search results in session vs keeping large object heap clean

Ok so I've been working on an ASP.NET project for a while and it seems I've made some bad design choices that are coming back to haunt me as the project keeps on getting bigger and bigger in terms of contained data. After reading up on .NET memory…
Nicolas78
  • 5,124
  • 1
  • 23
  • 41
6
votes
2 answers

Extensive use of LOH causes significant performance issue

We have a Web Service using WebApi 2, .NET 4.5 on Server 2012. We were seeing occasional latency increases by 10-30ms with no good reason. We were able to track down the problematic piece of code to LOH and GC. There is some text which we convert to…
Alon Catz
  • 2,417
  • 1
  • 19
  • 23
6
votes
1 answer

How to serialize a large collection

I'm working a system that has lists and dictionaries with over five million items where each item is typically a flat dto with up to 90 primitive properties. The collections are persisted to disk using protobuf-net for resilience and subsequence…
Joe
  • 333
  • 3
  • 10
6
votes
1 answer

If I use a MemoryStream for storing a half gigabyte chunk of data and then discard it what long term effect will it have?

In my Azure role running C# code inside a 64 bit process I want to download a ZIP file and unpack it as fast as possible. I figured I could do the following: create a MemoryStream instance, download to that MemoryStream, then pass the stream to some…
sharptooth
  • 167,383
  • 100
  • 513
  • 979
5
votes
3 answers

C#: Will GC collect if it needs memory, or will it give out of memory exception?

I have a loop in my code that generates many byte[] arrays (around 1 to 2 MB each), fills them with data, and then discard the reference. So, even though the reference is only held for a short time, I can see the private working set growing. Now,…
Jacko
  • 12,665
  • 18
  • 75
  • 126
5
votes
2 answers

Can Large Object Heap Fragmentation cause OutOfMemory in 64bit processes?

I'm preparing a presentation to my team on .net GC and memory. Different sources discuss the potential impact of fragmentation on Large Object Heap. Since it would be an interesting phenomenon to show, I'm trying to show that in code. Thomas Weller…
5
votes
1 answer

When are method local .NET objects eligible for GC?

Assume I have a C# method like this: (obviously not real code) byte[] foo() { var a = MethodThatReturns500mbObject(); var b = MethodThatReturns200mbObject(a); byte[] c = MethodThatReturns150mbByteArray(b); byte[] d =…
Justin Grant
  • 44,807
  • 15
  • 124
  • 208
5
votes
1 answer

Get list of object instances that are in LOH

I have several hundred instances of MyClass present in managed heap. Some of these are in large-object heap. Below is how various heap structure looks 0:000> !EEHeap -gc Number of GC Heaps: 1 generation 0 starts at 0x0000000002df9de8 generation 1…
paul deter
  • 857
  • 2
  • 7
  • 20
4
votes
2 answers

Reading large strings from database without fragmenting large object heap

I have data database containing some rather large strings, each of which holds a serialized hierarchical data collection (data is stored as strings rather than as a binary stream to allow interaction with VB6). From what I can tell, any database…
supercat
  • 77,689
  • 9
  • 166
  • 211