-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory Leak when using JsonSchemaValidator with Tomcat 7 #135
Comments
Hello, Do you have any more information? The only thing which potentially spawns threads in this package is the LoadingCache used to cache JSON Reference lookups... Not sure I have the means to rename the threads it generates. Also, if possible, can you do a kill -3 on the JVM when this "webapp" runs and post the thread dump? |
Ok did a thread dump (results below). The Thread names are (as far as I can tell) generated by Tomcats Executor I really don't know more. Just that somewhere JsonValidator and Tomcat clash Thread Dump: "pool-1-thread-6" #35 daemon prio=5 os_prio=0 tid=0x00007f670c28e800 nid=0x1b4a waiting on condition [0x00007f674e54b000] "pool-1-thread-5" #34 daemon prio=5 os_prio=0 tid=0x00007f670c28b000 nid=0x1b49 waiting on condition [0x00007f674e64c000] "pool-1-thread-4" #33 daemon prio=5 os_prio=0 tid=0x00007f670c28a800 nid=0x1b48 waiting on condition [0x00007f674e74d000] "pool-1-thread-3" #32 daemon prio=5 os_prio=0 tid=0x00007f670c1c9800 nid=0x1b47 waiting on condition [0x00007f674ea4e000] "pool-1-thread-2" #31 daemon prio=5 os_prio=0 tid=0x00007f670c1c8000 nid=0x1b46 waiting on condition [0x00007f674eb4f000] "pool-1-thread-1" #30 daemon prio=5 os_prio=0 tid=0x00007f670c1c6800 nid=0x1b45 waiting on condition [0x00007f674ec50000] "http-bio-8080-exec-10" #29 daemon prio=5 os_prio=0 tid=0x00007f673c127000 nid=0x1b43 waiting on condition [0x00007f674ffd8000] "http-bio-8080-exec-9" #28 daemon prio=5 os_prio=0 tid=0x00007f6734008800 nid=0x1b42 waiting on condition [0x00007f674fed7000] "http-bio-8080-exec-8" #27 daemon prio=5 os_prio=0 tid=0x00007f670c001000 nid=0x1b3a waiting on condition [0x00007f674edca000] "http-bio-8080-exec-7" #26 daemon prio=5 os_prio=0 tid=0x00007f6734006800 nid=0x1b39 waiting on condition [0x00007f674eecb000] "http-bio-8080-exec-6" #25 daemon prio=5 os_prio=0 tid=0x00007f6714001000 nid=0x1b38 waiting on condition [0x00007f674efcc000] "http-bio-8080-exec-5" #24 daemon prio=5 os_prio=0 tid=0x00007f6734005000 nid=0x1b37 waiting on condition [0x00007f674f0cd000] "http-bio-8080-exec-4" #23 daemon prio=5 os_prio=0 tid=0x00007f671c001000 nid=0x1b36 waiting on condition [0x00007f674f1ce000] "http-bio-8080-exec-3" #22 daemon prio=5 os_prio=0 tid=0x00007f6734003000 nid=0x1b35 waiting on condition [0x00007f674f2cf000] "http-bio-8080-exec-2" #21 daemon prio=5 os_prio=0 tid=0x00007f67240ae800 nid=0x1b34 waiting on condition [0x00007f674f3d0000] "http-bio-8080-exec-1" #20 daemon prio=5 os_prio=0 tid=0x00007f6734001800 nid=0x1b33 waiting on condition [0x00007f674f6d1000] "ajp-bio-8009-AsyncTimeout" #18 daemon prio=5 os_prio=0 tid=0x00007f679c4f3000 nid=0x1b32 waiting on condition [0x00007f674f7d2000] "ajp-bio-8009-Acceptor-0" #17 daemon prio=5 os_prio=0 tid=0x00007f679c4f1800 nid=0x1b31 runnable [0x00007f674f8d3000] "http-bio-8080-AsyncTimeout" #16 daemon prio=5 os_prio=0 tid=0x00007f679c4f0000 nid=0x1b30 waiting on condition [0x00007f674f9d4000] "http-bio-8080-Acceptor-0" #15 daemon prio=5 os_prio=0 tid=0x00007f679c4ee000 nid=0x1b2f runnable [0x00007f674fad5000] "ContainerBackgroundProcessor[StandardEngine[Catalina]]" #14 daemon prio=5 os_prio=0 tid=0x00007f679c4eb800 nid=0x1b2e waiting on condition [0x00007f674fbd6000] "GC Daemon" #11 daemon prio=2 os_prio=0 tid=0x00007f679c45f000 nid=0x1b2b in Object.wait() [0x00007f67847a0000] "Service Thread" #8 daemon prio=9 os_prio=0 tid=0x00007f679c0b8000 nid=0x1b29 runnable [0x0000000000000000] "C1 CompilerThread2" #7 daemon prio=9 os_prio=0 tid=0x00007f679c0b2800 nid=0x1b28 waiting on condition [0x0000000000000000] "C2 CompilerThread1" #6 daemon prio=9 os_prio=0 tid=0x00007f679c0b1000 nid=0x1b27 waiting on condition [0x0000000000000000] "C2 CompilerThread0" #5 daemon prio=9 os_prio=0 tid=0x00007f679c0ae000 nid=0x1b26 waiting on condition [0x0000000000000000] "Signal Dispatcher" #4 daemon prio=9 os_prio=0 tid=0x00007f679c0ac000 nid=0x1b25 waiting on condition [0x0000000000000000] "Finalizer" #3 daemon prio=8 os_prio=0 tid=0x00007f679c07d000 nid=0x1b23 in Object.wait() [0x00007f6786022000] "Reference Handler" #2 daemon prio=10 os_prio=0 tid=0x00007f679c07b000 nid=0x1b22 in Object.wait() [0x00007f6786123000] "main" #1 prio=5 os_prio=0 tid=0x00007f679c00a800 nid=0x1b1b runnable [0x00007f67a2b00000] "VM Thread" os_prio=0 tid=0x00007f679c073800 nid=0x1b21 runnable "GC task thread#0 (ParallelGC)" os_prio=0 tid=0x00007f679c01f800 nid=0x1b1c runnable "GC task thread#1 (ParallelGC)" os_prio=0 tid=0x00007f679c021800 nid=0x1b1d runnable "GC task thread#2 (ParallelGC)" os_prio=0 tid=0x00007f679c023000 nid=0x1b1e runnable "GC task thread#3 (ParallelGC)" os_prio=0 tid=0x00007f679c025000 nid=0x1b1f runnable "VM Periodic Task Thread" os_prio=0 tid=0x00007f679c0ba800 nid=0x1b2a waiting on condition JNI global references: 92 Heap |
Uh, no elements in any thread stack trace shows any code related to json-schema-validator :( This one is going to be a PITA to debug... |
yep very strange error indeed ... |
I switched over to tomcat 8.0.15 just to see if that changes anything. 18-Dec-2014 11:43:02.922 WARNING [http-nio-8080-exec-12] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [testApp] appears to have started a thread named [pool-2-thread-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread: |
Still no trace from -validator. Argh. OK well, since I don't create any ThreadPool by myself it has to be LoadingCache. I'll try and investigate on this front and see what can be done. From a cursory look however, it does not seem that there is a way to control its pool... |
Ah, I found something interesting: https://code.google.com/p/guava-libraries/issues/detail?id=517 And the bug is quite recent, too. Seems like I was on the right track. |
yes this seems to be the right direction. ANother Bug report dealing with memory leaks related to LoadingCache: |
What about jolly good old EHCache? It has all sort of expiration strategies and is very stable. |
@ddossot I had considered it at the very beginning -- until I stumbled upon Guava. Well, this has been a loong time now (nearly 2 years), and my first impression of ehcache was not very good; in particular, I recall a very complicated configuration for a simple cache and that keys and values had to implement Well, I guess I can try again. |
Yeah, the config side of things of ehcache could be a little off putting. Regarding serializable key/values, this requirement has been lifted since version 1.2 (see http://ehcache.org/apidocs/2.6.9/index.html?net/sf/ehcache/Element.html ). |
any news on this? The issue in the other framework that you wanted to see fixed has been marked as closed: |
We are hitting an issue with a seeming leak. When I do a jmap the dump strongly indicates the cache used by json-schema-validator/cores are the primary cause. A colleague of mine pointed out that maximumSize isn't being set on any of the caches as a possible culprit. This may be a seperate issue from the main one in this thread but it seemed worth starting here. Also the majority of the items that are filling the cache are ProcessingResults (a guava cache is used there as well) and also doesn't have a max size. I assume both are leaking but we have way more ProcessingResults. Thoughts? |
Hi guys, thanks to Tomcat I am here too, but the truth is the issue has nothing to do with it. Debugging a simple application with the previous code snippet is enough to see these threads are being started too. Here is the stack at the point where the executor is executed:
being the issue in this class: com/github/fge/msgsimple/provider/LoadingMessageSourceProvider
|
Maybe the author can give us a hint on why using multithreading here? |
Hi, I have similar issue, why this is mark as closed? I am using 2.2.6. I only added this following code and it started a ThreadPool with no way to closed it. Thanks to @idelvall have managed to track down until get LoadingMessageSourceProvider Any updates on this issue ? |
This change worked for me: brutusin/json-provider@338c723 Just add this class to your source code, and try, the class loader should resolve to this class definition instead of the original one |
@idelvall Thanks for the response. I will try it out. |
I can confirm this issue, json-schema-validator is flooding my memory with cached ProcessingResults and alikes. I tried @idelvall 's fix to no avail. Is anyone looking into this? |
@mvrajumca @febpetroni this should be fixed in group: "com.github.java-json-tools", name: "json-schema-validator", version: "2.2.8". Context: @fge has stepped away from the project. I own the github page now, but can't publish to his old maven central group. That's why the group moved. |
Or at least the thing that @febpetroni talked about is fixed in 2.2.8. It is a cache with unbounded size growing over time. |
@huggsboson I am using version 2.2.8 json-schema-validator, I also found memory leak exists. I using eclipse MAT found that the biggest objects is |
I wanted to use JsonSchemaValidator on a Tomcat application (Tomcat 7.0.55).
I have noticed that Tomcat logs a SEVERE error about memory leaks. I could reproduce this with the following simple setup:
Netbeans 8:
New Project > Maven > Web Applikation
Use Apache Tomcat as Server; Use Java 7 EE Web as Java Version
Add JsonSchemaValidator to the projects POM
Create a new Java Class:
Build the Applikation
Run/Deploy the Appliaktion
Clean/Undeploy the Applikation
Tomcat will log the following error:
The problem seems to correspond to this Tomcat Wiki Entry:
http://wiki.apache.org/tomcat/MemoryLeakProtection#cclThreadSpawnedByWebApp
The text was updated successfully, but these errors were encountered: