{"action":"created","issue":{"url":"https://api.github.com/repos/serilog/serilog/issues/293","labels_url":"https://api.github.com/repos/serilog/serilog/issues/293/labels{/name}","comments_url":"https://api.github.com/repos/serilog/serilog/issues/293/comments","events_url":"https://api.github.com/repos/serilog/serilog/issues/293/events","html_url":"https://github.com/serilog/serilog/issues/293","id":49314010,"number":293,"title":"[ElasticsearchSink] OutOfMemory exception","user":{"login":"chuwik","id":403428,"avatar_url":"https://avatars.githubusercontent.com/u/403428?v=3","gravatar_id":"","url":"https://api.github.com/users/chuwik","html_url":"https://github.com/chuwik","followers_url":"https://api.github.com/users/chuwik/followers","following_url":"https://api.github.com/users/chuwik/following{/other_user}","gists_url":"https://api.github.com/users/chuwik/gists{/gist_id}","starred_url":"https://api.github.com/users/chuwik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chuwik/subscriptions","organizations_url":"https://api.github.com/users/chuwik/orgs","repos_url":"https://api.github.com/users/chuwik/repos","events_url":"https://api.github.com/users/chuwik/events{/privacy}","received_events_url":"https://api.github.com/users/chuwik/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2014-11-19T00:37:48Z","updated_at":"2015-01-19T23:08:08Z","closed_at":null,"body":"Hi,\r\n\r\nI have a system using Serilog with the ElasticSearch sink, generating a big volume of logs (~45 million log entries / 24h) and sometimes at high frequency. The problem is that sometimes I get an OutOfMemory exception when I use the ElasticSearch sink; if I use the File sink, for instance, there's no problem. I don't have a clear repro from the code in my system, but I have observed it usually happens when there's a high frequency of logs being created.\r\n\r\nI've been able to replicate the issue by tweaking the Serilog.PerformanceTests to use the ElasticSearch sink and more iterations:\r\n\r\n    static void Main()\r\n    {\r\n        const int iterations = 10000000;\r\n        var log = new LoggerConfiguration()\r\n                .WriteTo.ElasticSearch(node: new Uri(\"http://localhost:9200\"))\r\n                .CreateLogger();\r\n\r\n        for (var i = 0; i < iterations; i++)\r\n        {\r\n            log.Information(\"Running iteration {I:00.0} for {@J}!\", i, new { Goal = \"Speed\" });\r\n        }\r\n    }\r\n\r\nIt throws the OutOfMemory exception for me a bit over the 7000000 one. It works fine with the File sink.\r\n\r\nIs there any configuration of the ElasticSearch sink that I'm missing and could use to handle this scenario (high volume/frequency)? Is there any documented \"ceiling\" for how much the sink can take? Or is it just a bug/improvement needed in the code?\r\n\r\nRight now I have to default to enabling both the ElasticSearch and File sinks (the latter just for error & up) just to make sure I don't miss anything... which is quite annoying! Hopefully there'll be a fix for this :)\r\n\r\nThanks a lot"},"comment":{"url":"https://api.github.com/repos/serilog/serilog/issues/comments/70577203","html_url":"https://github.com/serilog/serilog/issues/293#issuecomment-70577203","issue_url":"https://api.github.com/repos/serilog/serilog/issues/293","id":70577203,"user":{"login":"mivano","id":668535,"avatar_url":"https://avatars.githubusercontent.com/u/668535?v=3","gravatar_id":"","url":"https://api.github.com/users/mivano","html_url":"https://github.com/mivano","followers_url":"https://api.github.com/users/mivano/followers","following_url":"https://api.github.com/users/mivano/following{/other_user}","gists_url":"https://api.github.com/users/mivano/gists{/gist_id}","starred_url":"https://api.github.com/users/mivano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mivano/subscriptions","organizations_url":"https://api.github.com/users/mivano/orgs","repos_url":"https://api.github.com/users/mivano/repos","events_url":"https://api.github.com/users/mivano/events{/privacy}","received_events_url":"https://api.github.com/users/mivano/received_events","type":"User","site_admin":false},"created_at":"2015-01-19T23:08:08Z","updated_at":"2015-01-19T23:08:08Z","body":"I can reproduce the rapid increase in memory now. On Mono however, but it shows the same problem and will hit the ceiling at some point. I have no idea what to do about this. Looked for points where we might not dispose stuff but it all looks okay. Maybe @Mpdreamz has some ideas? "}}