{"action":"created","issue":{"url":"https://api.github.com/repos/spring-cloud/spring-cloud-netflix/issues/3711","repository_url":"https://api.github.com/repos/spring-cloud/spring-cloud-netflix","labels_url":"https://api.github.com/repos/spring-cloud/spring-cloud-netflix/issues/3711/labels{/name}","comments_url":"https://api.github.com/repos/spring-cloud/spring-cloud-netflix/issues/3711/comments","events_url":"https://api.github.com/repos/spring-cloud/spring-cloud-netflix/issues/3711/events","html_url":"https://github.com/spring-cloud/spring-cloud-netflix/issues/3711","id":538489942,"node_id":"MDU6SXNzdWU1Mzg0ODk5NDI=","number":3711,"title":"OutOfMemory handling","user":{"login":"lafual","id":16446835,"node_id":"MDQ6VXNlcjE2NDQ2ODM1","avatar_url":"https://avatars0.githubusercontent.com/u/16446835?v=4","gravatar_id":"","url":"https://api.github.com/users/lafual","html_url":"https://github.com/lafual","followers_url":"https://api.github.com/users/lafual/followers","following_url":"https://api.github.com/users/lafual/following{/other_user}","gists_url":"https://api.github.com/users/lafual/gists{/gist_id}","starred_url":"https://api.github.com/users/lafual/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lafual/subscriptions","organizations_url":"https://api.github.com/users/lafual/orgs","repos_url":"https://api.github.com/users/lafual/repos","events_url":"https://api.github.com/users/lafual/events{/privacy}","received_events_url":"https://api.github.com/users/lafual/received_events","type":"User","site_admin":false},"labels":[{"id":222072230,"node_id":"MDU6TGFiZWwyMjIwNzIyMzA=","url":"https://api.github.com/repos/spring-cloud/spring-cloud-netflix/labels/waiting%20for%20feedback","name":"waiting for feedback","color":"fbca04","default":false,"description":null}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2019-12-15T07:57:00Z","updated_at":"2019-12-23T16:14:01Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nI am running a Gateway with Eureka (Boot 2.2.2 HOXTON.RELEASE). On the Gateway I have an end-point which is checking all routes in real-time. \r\n\r\nThe end point is as follows;\r\n\r\n```\r\n@GetMapping(value = \"/applicationStatus\", produces = MediaType.TEXT_EVENT_STREAM_VALUE)\r\npublic Flux<MyApplication> getApplicationActuator() {\r\n\tWebClient webClient = loadBalanced.build();\r\n\treturn webClient\r\n\t\t.get().uri(\"lb://SECURITY/applications\")  // get a list of Routes\r\n\t\t.retrieve()\r\n\t\t.bodyToFlux(MyApplication.class)\r\n\t\t.filter(p -> p.isActive())\r\n\t\t.flatMap(myApplication ->\r\n\t\t\tloadBalanced.build()\r\n\t\t\t\t.get().uri(\"lb://\" + myApplication.getName() + \"/actuator/health\")\r\n\t\t\t\t.retrieve()\r\n\t\t\t\t.bodyToMono(ActuatorStatus.class)\r\n\t\t\t\t.onErrorReturn(new ActuatorStatus(\"DOWN\"))\r\n\t\t\t\t.map(as -> {\r\n\t\t\t\t\tmyApplication.setStatus(as.getStatus());\r\n\t\t\t\t\treturn myApplication;\r\n\t\t\t\t})\r\n\t\t\t.repeatWhen(interval -> Flux.interval(Duration.ofSeconds(4)))\r\n\t\t);\r\n}\r\n```\r\n\r\nThere are 7 routes which are queried every 4 seconds.\r\n\r\nWith only one browser running this endpoint, after sometime I got the following repetitively for > 12 hours, until I restarted the process;\r\n\r\n```\r\n2019-12-12 23:34:49.087 ERROR 2272 --- [DiscoveryClient-CacheRefreshExecutor-0] com.netflix.discovery.DiscoveryClient    : Cannot fetch registry from server\r\njava.lang.OutOfMemoryError: Java heap space: failed reallocation of scalar replaced objects\r\n2019-12-12 23:35:19.707 ERROR 2272 --- [DiscoveryClient-CacheRefreshExecutor-0] com.netflix.discovery.DiscoveryClient    : Cannot fetch registry from server\r\njava.lang.OutOfMemoryError: Java heap space\r\n```\r\n\r\nAdmittedly, I was running the Gateway with `-xmx64m` and have since upped to `-xmx128m`. Since then I haven't seen the problem.\r\n\r\nHowever, my questions are;\r\n1. Is it feasible to recommend an `xm` for the Gateway or does it depend on what I am doing (so _suck it and see_)\r\n2. I believe that the `OutOfMemoryError` is not recoverable from a Java point of view. When my application gets to this point it reports the error repetitively. As a consequence, this process took 99% CPU on the server and starved every other process. On catching this error, shouldn't the code effectively fail and return -1 to the OS, so that the outer layer has a chance to deal with it and restart the JVM? As far as I can tell, the error never gets rippled to my code, so there is nothing I can do about it (apart from change `-xmx` again).\r\n3. Shouldn't the above error give a stack trace, not just return the error? (just to clarify whether the error is rippled to my code or not).\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/spring-cloud/spring-cloud-netflix/issues/comments/568515476","html_url":"https://github.com/spring-cloud/spring-cloud-netflix/issues/3711#issuecomment-568515476","issue_url":"https://api.github.com/repos/spring-cloud/spring-cloud-netflix/issues/3711","id":568515476,"node_id":"MDEyOklzc3VlQ29tbWVudDU2ODUxNTQ3Ng==","user":{"login":"spring-issuemaster","id":16028288,"node_id":"MDQ6VXNlcjE2MDI4Mjg4","avatar_url":"https://avatars2.githubusercontent.com/u/16028288?v=4","gravatar_id":"","url":"https://api.github.com/users/spring-issuemaster","html_url":"https://github.com/spring-issuemaster","followers_url":"https://api.github.com/users/spring-issuemaster/followers","following_url":"https://api.github.com/users/spring-issuemaster/following{/other_user}","gists_url":"https://api.github.com/users/spring-issuemaster/gists{/gist_id}","starred_url":"https://api.github.com/users/spring-issuemaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spring-issuemaster/subscriptions","organizations_url":"https://api.github.com/users/spring-issuemaster/orgs","repos_url":"https://api.github.com/users/spring-issuemaster/repos","events_url":"https://api.github.com/users/spring-issuemaster/events{/privacy}","received_events_url":"https://api.github.com/users/spring-issuemaster/received_events","type":"User","site_admin":false},"created_at":"2019-12-23T16:14:01Z","updated_at":"2019-12-23T16:14:01Z","author_association":"NONE","body":"If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.\n"}}
{"actor":{"display_login":"spring-issuemaster"}}