# Java.lang.OutMemoryError

**URL:** <https://discuss.elastic.co/t/java-lang-outmemoryerror/84001>\
**Category:** Logstash\
**Created:** [April 28, 2017, 10:57am UTC](https://discuss.elastic.co/t/java-lang-outmemoryerror/84001 "2017-04-28T10:57:55Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![vineets928](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineets928/32/94852_2.png) [@vineets928](https://discuss.elastic.co/u/vineets928)\
**Post date:** [April 28, 2017, 10:57am UTC](https://discuss.elastic.co/t/java-lang-outmemoryerror/84001/1 "2017-04-28T10:57:55Z")

</div>

Hi,

I have to migrate mysql data to elasticsearch. My logstash configuration file is

 ![](https://us1.discourse-cdn.com/elastic/original/3X/5/b/5b6903f03862c06e46a58f2f8454036318756ea6.JPG)

Getting error when starting logstash

 ![](https://us1.discourse-cdn.com/elastic/original/3X/1/7/179b3986c236e30646e75eee5ca92741cd55d66f.JPG)

In logstash configuration file, changed the JVM configuration to 512m and 8g. But after restating, logstash giving the same error.  
Please help me to resolve the issue.

---

<div class="post-metadata">

**Author:** ![Xavy](https://avatars.discourse-cdn.com/v4/letter/x/e0b2c6/32.png) [@Xavy](https://discuss.elastic.co/u/Xavy)\
**Post date:** [April 28, 2017, 12:15pm UTC](https://discuss.elastic.co/t/java-lang-outmemoryerror/84001/2 "2017-04-28T12:15:13Z")

</div>

Hi there:

Just to confirm, when you changed LS VM Memory HEAP Size you did change both mininum and maximum, did you?

How big is the database you're trying to migrate?

---

<div class="post-metadata">

**Author:** ![vineets928](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineets928/32/94852_2.png) [@vineets928](https://discuss.elastic.co/u/vineets928)\
**Post date:** [April 28, 2017, 12:24pm UTC](https://discuss.elastic.co/t/java-lang-outmemoryerror/84001/3 "2017-04-28T12:24:17Z")

</div>

Thanks Xavy for reply...

Yes i changed both minimum and maximum value. And my database is of 12.5 GB.

---

<div class="post-metadata">

**Author:** ![Xavy](https://avatars.discourse-cdn.com/v4/letter/x/e0b2c6/32.png) [@Xavy](https://discuss.elastic.co/u/Xavy)\
**Post date:** [April 28, 2017, 12:46pm UTC](https://discuss.elastic.co/t/java-lang-outmemoryerror/84001/4 "2017-04-28T12:46:16Z")

</div>

Hi again :

Have you tried to temporarily increase the HEAP to at least the size of the database? Or probably incorporate the queries with some where statement to reduce the output size so it fit into the HEAP size

---

<div class="post-metadata">

**Author:** ![vineets928](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineets928/32/94852_2.png) [@vineets928](https://discuss.elastic.co/u/vineets928)\
**Post date:** [April 28, 2017, 12:54pm UTC](https://discuss.elastic.co/t/java-lang-outmemoryerror/84001/5 "2017-04-28T12:54:22Z")

</div>

Thanks Xavy..

It means i have to assign 13gb heap size in JVM. But i have 16 gb RAM, so is it feasible to assign 13gb to JVM?

Let me try using where statement.

---

<div class="post-metadata">

**Author:** ![Xavy](https://avatars.discourse-cdn.com/v4/letter/x/e0b2c6/32.png) [@Xavy](https://discuss.elastic.co/u/Xavy)\
**Post date:** [April 28, 2017, 12:58pm UTC](https://discuss.elastic.co/t/java-lang-outmemoryerror/84001/6 "2017-04-28T12:58:04Z")

</div>

You should be able to assign that size... as long as you have enough free memory. Anyway, probably you would be too near from the limit system began to swap which obviously is not a good thing at all.

So we'll be waiting for you test using where statements, to check whether it might help.

---

<div class="post-metadata">

**Author:** ![vineets928](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineets928/32/94852_2.png) [@vineets928](https://discuss.elastic.co/u/vineets928)\
**Post date:** [April 28, 2017, 1:36pm UTC](https://discuss.elastic.co/t/java-lang-outmemoryerror/84001/7 "2017-04-28T13:36:25Z")

</div>

Hi Xavy

After limiting the select statement, now it works. 🙂

---

<div class="post-metadata">

**Author:** ![vineets928](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineets928/32/94852_2.png) [@vineets928](https://discuss.elastic.co/u/vineets928)\
**Post date:** [April 28, 2017, 1:37pm UTC](https://discuss.elastic.co/t/java-lang-outmemoryerror/84001/8 "2017-04-28T13:37:58Z")

</div>

Hi Xavy,

Thanks a ton...

Can you please suggest any method so that i can migrate whole data.

---

<div class="post-metadata">

**Author:** ![Xavy](https://avatars.discourse-cdn.com/v4/letter/x/e0b2c6/32.png) [@Xavy](https://discuss.elastic.co/u/Xavy)\
**Post date:** [April 28, 2017, 1:52pm UTC](https://discuss.elastic.co/t/java-lang-outmemoryerror/84001/9 "2017-04-28T13:52:20Z")

</div>

Case the machine were a VM I absolutely would go for increasing RAM and increasing the max heap size to the whole size of the database.

Case machine is physical, you could stop any non needed service and check how much RAM you have available (with LS stopped) If then you have more than those 13gb free, then I would go for temporarily increase the Heap size.

Case RAM were not enough I would try doing the migration by parts, this is to run first with a particular select .. where, then with other.. and so on .

Another possibility so this might not take as much time would be to define several jdbc input entries, but I'm not sure this would work or not (depends on if LS processes those entries in a serialized mode - it should work - or in a paralellized mode - then java would run out of memory again). This being said, most probable thing is that inputs are handled in parallel so this might not be the solution (the single WHERE'd statements should)

---

<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:** [May 26, 2017, 1:58pm UTC](https://discuss.elastic.co/t/java-lang-outmemoryerror/84001/10 "2017-05-26T13:58:33Z")

</div>

Closed on May 26, 2017, 1:58pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
