# How to read textfiles dynamically from folder and keep listining without jump out Heap Size Memory

**URL:** <https://discuss.elastic.co/t/how-to-read-textfiles-dynamically-from-folder-and-keep-listining-without-jump-out-heap-size-memory/181557>\
**Category:** Logstash\
**Created:** [May 17, 2019, 9:38am UTC](https://discuss.elastic.co/t/how-to-read-textfiles-dynamically-from-folder-and-keep-listining-without-jump-out-heap-size-memory/181557 "2019-05-17T09:38:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![samyo](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@samyo](https://discuss.elastic.co/u/samyo)\
**Post date:** [May 17, 2019, 9:38am UTC](https://discuss.elastic.co/t/how-to-read-textfiles-dynamically-from-folder-and-keep-listining-without-jump-out-heap-size-memory/181557/1 "2019-05-17T09:38:44Z")

</div>

Hello folks,  
i am using Elasticsearch and Logstash Version 6.3.1 , and Java version 8 , on Ubunto Virtualmachine , with 8GB RAM and 50GB for the Memory .  
I am trying to read and match 8000 textfiles from folder using multline Codec after filter them using Logstash , and send them to Elasticsearch and **keep listining** from folder if any new textfile has been added so logstash will read it and send it to elastic and so on.

My Input seems not to be Confidence , cause after matching and sending about 5000 textfiles , **logstash jump out of Java Heap Size Memory Space.**  
Can anybody please correct my Input bellow:

```auto
input {
file {
path => "/home/sam/Desktop/folder2/*.txt"
sincedb_path => "/dev/null"
start_position => "beginning"
stat_interval => 300
discover_interval => 1
ignore_older => 864000
close_older => 20
max_open_files => 102400
        codec => multiline
       {
            pattern => "^\s"
            negate => true
            what => previous		
        }
}
}

```

how to write an Input that listining from folder if any textfiles has been added , with out jumping out of Heap Size Memory Space????

i will be thankfull for any Idea.

---

<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:** [June 14, 2019, 9:39am UTC](https://discuss.elastic.co/t/how-to-read-textfiles-dynamically-from-folder-and-keep-listining-without-jump-out-heap-size-memory/181557/2 "2019-06-14T09:39:12Z")

</div>

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