Comments (10)
@todesking Thanks for your report.
@muga Why did you change the implementation of Map from HashMap to WeakHashMap at d5efd4d?
from fluent-logger-java.
@muga Any updates?
from fluent-logger-java.
@todesking We've used WeakHashMap and finalize method for reducing the heap space consumption. I thought and considered the possibility that some users create a lot of FluentLogger objects on his JVM. But the implementation is not good in some cases, you know.
@komamitsu We should remove FluentLoggerFactory (and the WeakHashMap impl.) from external API. FluentLogger objects and the object creations should be managed by users.
from fluent-logger-java.
@todesking good catch, thanks for your report.
We have 2 options:
- Reverting the store of FluentLoggerFactory to HashMap.
- Removing FluentLoggerFactory.
I prefer to use 1. for the backward compatibility. Also, users can choose whether they manage the object by themselves or by FluentLoggerFactory. For handling small number of the objects, it's enough.
from fluent-logger-java.
@muga @oza Thanks for your ideas.
For option 1, I'm concerned about memory consumption because all FluentLoggers stored in HashMap are never released. I think option 2 is simple and isn't confusable. Of course, backward compatibility is important, though as you said.
Also, users can choose whether they manage the object by themselves or by FluentLoggerFactory.
FluentLogger internally depends on FluentLogFactory. https://github.com/fluent/fluent-logger-java/blob/master/src/main/java/org/fluentd/logger/FluentLogger.java#L32. So we need to remove the dependency from FluentLogger if we choose this option.
from fluent-logger-java.
@komamitsu Rethinking of this - how about having the key of WeakHashMap at FluentLogger via FluentLogger#setFactoryKey or something to prevent the GC? When a instance of FluentLogger#close()
is called, resource management can be done by setting key as null.
from fluent-logger-java.
@oza Make sense.
But adding another attribute into FluentLogger may make it more complicated. Also, factoryKey doesn't sound an essential information for FluentLogger...
I think the cause of this problem is the way of holding a reference of FluentLogger in FluentLoggerFactory. I created a PR (#38) for it. The PR has the following little downsides. But I think they are ignorable.
- FluentLoggerFactory#getLogger linearly searches for a FluentLogger which has the same key consists of
tagPrefix
,host
,port
and so on. But the number of FluentLogger entries won't be large actually. - FluentLoggerFactory#getLoggers broke the compatibility. But this method is package private and only for test.
What do you think?
from fluent-logger-java.
@komamitsu I agree with your idea. @muga what do you think?
from fluent-logger-java.
@komamitsu @oza thank you for driving this issue and fixing. #38 looks good to me to fix this issue. compatibility is important:-)
from fluent-logger-java.
@muga @komamitsu Merged #38.
@todesking Thanks for your reporting!
from fluent-logger-java.
Related Issues (20)
- Bad thread interleaving may cause unexpected crash
- Current Error Handling does not return false on logging errors HOT 3
- NullPointerException when the Fluentd server is down
- API changes report for Fluent Logger HOT 1
- support fluentd with secure_forward HOT 1
- java.net.SocketException: Broken pipe HOT 4
- FluentLoggerFactory not invalidate cache after FluentLogger close
- Calling `.close()` does not clean up instance in `FluentLoggerFactory` HOT 2
- NPE in RawSocketSender HOT 1
- There is no way to set socket read timeout HOT 1
- Conflict with Spring cloud SpringApplication run
- Release 0.3.4? HOT 2
- Connection Reset on calling Fluentlogger.log() HOT 3
- Conflict with Spring Webflux
- How to pass credentials to connect remote fluentD aggregator HOT 1
- Null Pointer Exception with slf4j-log4j12-1.7.30 (Fluent-logger incompatible with the new version) HOT 3
- is this libarary can be used for fluent-bit? HOT 1
- log4j JNDI vulnerability HOT 4
- Add Support For Unix Domain Sockets HOT 1
- Is this library still maintained?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluent-logger-java.