# System.OutOfMemoryException - Nest Elasticsearch

**URL:** <https://discuss.elastic.co/t/system-outofmemoryexception-nest-elasticsearch/53300>\
**Category:** Elasticsearch\
**Created:** [June 20, 2016, 9:53am UTC](https://discuss.elastic.co/t/system-outofmemoryexception-nest-elasticsearch/53300 "2016-06-20T09:53:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ASN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asn/32/10535_2.png) [@ASN](https://discuss.elastic.co/u/ASN)\
**Post date:** [June 20, 2016, 9:53am UTC](https://discuss.elastic.co/t/system-outofmemoryexception-nest-elasticsearch/53300/1 "2016-06-20T09:53:57Z")

</div>

Off Late I've been facing the below issue a lot(sometimes even while indexing a large document it has this problem). Can some one tell me what can be the reason behind this?

I just tried to run a simple search application which will return a 5 documents sorted in descending order of indexed date.

```
var response = client.Search<Document>(s => s
                                   .Size(5)
                                   .Sort(so => so
                                   .Descending(d => d
                                   .IndexedDate)));

```

The same code works perfectly fine when I run on the local host. Dont know whats wrong if I run the application on the server.

> FailureReason: Unexpected when trying to POST [http://192.168.x.y:9200/codetweaks54/document/\_search](http://192.168.x.y:9200/codetweaks54/document/_search)
> 
> - BadResponse: Node: [http://192.168.x.y:9200/](http://192.168.x.y:9200/) Exception: OutOfMemoryException Took: 00:00:20.3557156  
> Audit exception in step 0 BadResponse:  
> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.  
> at Newtonsoft.Json.Utilities.BufferUtils.RentBuffer(IArrayPool 1 bufferPool, Int32 minSize)  
> at Newtonsoft.Json.JsonTextReader.ReadData(Boolean append, Int32 charsRequired)  
> at Newtonsoft.Json.JsonTextReader.ReadData(Boolean append)  
> at Newtonsoft.Json.JsonTextReader.ReadStringIntoBuffer(Char quote)  
> at Newtonsoft.Json.JsonTextReader.ParseString(Char quote, ReadType readType)  
> at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType)  
> at Newtonsoft.Json.JsonTextReader.ReadAsString()  
> at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)  
> at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)  
> at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)  
> at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)  
> at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)  
> at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)  
> at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)  
> at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)  
> at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)  
> at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)  
> at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Populate(JsonReader reader, Object target)  
> at Newtonsoft.Json.Serialization.JsonSerializerProxy.PopulateInternal(JsonReader reader, Object target)  
> at Newtonsoft.Json.JsonSerializer.Populate(JsonReader reader, Object target)  
> at Nest.ConcreteTypeConverter`

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 20, 2016, 10:14am UTC](https://discuss.elastic.co/t/system-outofmemoryexception-nest-elasticsearch/53300/2 "2016-06-20T10:14:17Z")

</div>

Again. This is not related to elasticsearch code IMO.

You should move your question to #development channel I think.

Unless you see in elasticsearch nodes a trace?

---

<div class="post-metadata">

**Author:** ![ASN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asn/32/10535_2.png) [@ASN](https://discuss.elastic.co/u/ASN)\
**Post date:** [June 20, 2016, 11:04am UTC](https://discuss.elastic.co/t/system-outofmemoryexception-nest-elasticsearch/53300/3 "2016-06-20T11:04:50Z")

</div>

Yeah. I remember posting a similar question which as you said is not problem with ES after looking at my code. But this time its giving a problem only at few instances. like local server is perfectly fine while running it on a different server is throwing this. Thats why posted this question again.  
Anyways will move it to development.

Thanks David.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:42pm UTC](https://discuss.elastic.co/t/system-outofmemoryexception-nest-elasticsearch/53300/4 "2017-07-05T22:42:20Z")

</div>


