title: Scheduled task causes OutOfMemoryError (Spring Boot)
body: <p>Application works fine until scheduled task starts in back end. This task updates posts from cloud database and if where is a change it rewrites existing post. after it updates about 400 - 500 posts , application crashes H2 database and gives an error : Exception in thread "File Watcher" java.lang.OutOfMemoryError: Java heap space</p>
  
  <p>My sheduled task </p>
  
  <pre><code> @Scheduled(cron = "0 0 15 ? * SUN")
    public void updateAllWeekly() {
      log.debug(
          "&lt;&lt; UPDATE ALL &gt;&gt; CRON IS STARTED. The time is now {}", dateFormat.format(new Date()));
      postService.updateAll();
    }
  </code></pre>
  
  <p>updateAll method </p>
  
  <pre><code>  public void updateAll() {
  
      try {
  
        Long startId = 0L;
  
        do {
          startId = updateFrom(startId);
        } while (startId &gt; 0);
  
      } catch (FeignException ex) {
        log.debug("CALL ERROR", ex.contentUTF8());
        return;
      }
    }
  </code></pre>
  
  <p>updateFrom method </p>
  
  <pre><code>public Long updateFrom(Long startId) {
  
      Long lastd = startId;
  
      try {
        List&lt;Post&gt; posts = cloud.pullPostsFromId(startId)
        int postSize = posts.size();
  
        if (postSize &gt; 0) {
          lastd = posts.get(postSize - 1).getId();
        } else {
          startId = -1L;
          return startId;
        }
  
        for (Post post : posts) {
  
          updatePost(post);
        }
  
      } catch (FeignException ex) {
        log.debug("CALL ERROR");
      }
  
      return lastd + 1;
    }
  </code></pre>
  
  <p>updatePost method finds Post by id (post.getId) sets changed parameters ( if any ) and save it back to database</p>
  
  <p>Full error :</p>
  
  <pre><code>Exception in thread "File Watcher" java.lang.OutOfMemoryError: Java heap space
      at java.base/java.util.Arrays.copyOfRange(Arrays.java:3821)
      at java.base/java.lang.StringLatin1.newString(StringLatin1.java:767)
      at java.base/java.lang.String.substring(String.java:1907)
      at java.base/java.lang.String.substring(String.java:1875)
      at java.base/java.io.File.getName(File.java:459)
      at java.base/java.io.UnixFileSystem.getBooleanAttributes(UnixFileSystem.java:262)
      at java.base/java.io.File.isFile(File.java:886)
      at org.springframework.boot.devtools.filewatch.FolderSnapshot.collectFiles(FolderSnapshot.java:69)
      at org.springframework.boot.devtools.filewatch.FolderSnapshot.collectFiles(FolderSnapshot.java:67)
      at org.springframework.boot.devtools.filewatch.FolderSnapshot.collectFiles(FolderSnapshot.java:67)
      at org.springframework.boot.devtools.filewatch.FolderSnapshot.collectFiles(FolderSnapshot.java:67)
      at org.springframework.boot.devtools.filewatch.FolderSnapshot.collectFiles(FolderSnapshot.java:67)
      at org.springframework.boot.devtools.filewatch.FolderSnapshot.&lt;init&gt;(FolderSnapshot.java:58)
      at org.springframework.boot.devtools.filewatch.FileSystemWatcher$Watcher.getCurrentSnapshots(FileSystemWatcher.java:277)
      at org.springframework.boot.devtools.filewatch.FileSystemWatcher$Watcher.scan(FileSystemWatcher.java:251)
      at org.springframework.boot.devtools.filewatch.FileSystemWatcher$Watcher.run(FileSystemWatcher.java:236)
      at java.base/java.lang.Thread.run(Thread.java:832)
  </code></pre>