Skip to content

Conversation

@tejksat
Copy link
Contributor

@tejksat tejksat commented Jul 12, 2016

According to https://github.com/netty/netty/wiki/Reference-counted-objects tests logs should be checked for an error message about a memory leak:

PARANOID - Same with ADVANCED except that it's for every single buffer. Useful for automated testing phase. You could fail the build if the build output contains 'LEAK:'.

I don't know how to implement it in a good way. Could you please suggest?

Fixes #624


This change is Reviewable

@tejksat
Copy link
Contributor Author

tejksat commented Jul 24, 2016

@marcuslinke @KostyaSha could you please check the changes? Please also note the question in the comment above.

@KostyaSha
Copy link
Member

Sorry, lost comment. Could you check coverity results for master branch? Does it has complains about this resource leak? https://scan.coverity.com/projects/docker-java-docker-java?tab=overview

@tejksat
Copy link
Contributor Author

tejksat commented Jul 30, 2016

@KostyaSha sure! I've requested the access to coverty.

@KostyaSha
Copy link
Member

Hm.. you should be able to see any defects without contributor... Press "view defects"

@tejksat
Copy link
Contributor Author

tejksat commented Aug 1, 2016

@KostyaSha when I sign in as GitHub user Coverity shows a message Want to view defects or help fix defects? with a button below Add me to project.
image

@KostyaSha
Copy link
Member

Added as defect viewer, if you will need "triage?" please ping me.

@KostyaSha
Copy link
Member

@marcuslinke for review

@tejksat
Copy link
Contributor Author

tejksat commented Aug 1, 2016

@KostyaSha thank you! HttpResponseStreamHandler is clean. Does Coverity could find problems with not released Netty buffers?

@KostyaSha
Copy link
Member

As i understand it analyses only our code and nobody knows what checks it has because it proprietary solution.

@tejksat
Copy link
Contributor Author

tejksat commented Aug 1, 2016

Ok.. I'll try to find a solution to check generated logs for messages about ByteBuf leaks. I've checked them locally and on downloading a somewhat big file there is a resource leak message there.

@tejksat
Copy link
Contributor Author

tejksat commented Aug 25, 2016

@KostyaSha @marcuslinke could you please check? Travis errors don't seem to be related with PR changes.

@KostyaSha
Copy link
Member

@tejksat 1.11 tcp build is green and it fine, 1.12 tcp shouldn't have new failures (atm only #670 fails)

public void onError(Throwable throwable) {
if (closed) return;

if (this.firstError == null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't use this where it not required.

@tejksat tejksat force-pushed the fixHttpResponseInputStreamResourceLeak branch from 27bffd6 to 0cb0b08 Compare August 29, 2016 11:13
@codecov-io
Copy link

codecov-io commented Aug 29, 2016

Current coverage is 71.02% (diff: 78.94%)

Merging #633 into master will decrease coverage by 0.01%

@@             master       #633   diff @@
==========================================
  Files           300        301     +1   
  Lines          6131       6225    +94   
  Methods           0          0          
  Messages          0          0          
  Branches        518        532    +14   
==========================================
+ Hits           4355       4421    +66   
- Misses         1526       1550    +24   
- Partials        250        254     +4   

Powered by Codecov. Last update eaef1ac...0cb0b08

@tejksat tejksat force-pushed the fixHttpResponseInputStreamResourceLeak branch from 0cb0b08 to 1871e6d Compare August 29, 2016 12:37
@tejksat
Copy link
Contributor Author

tejksat commented Aug 29, 2016

@KostyaSha pls review!

@KostyaSha
Copy link
Member

@tejksat https://github.com/codecov/browser-extension if you would like to cover all your logic :)

@KostyaSha
Copy link
Member

@tejksat i don't understand this routines, would wait bit for @marcuslinke or merge as it passes tests.

@tejksat
Copy link
Contributor Author

tejksat commented Aug 31, 2016

@KostyaSha codecov Chrome extension is the best! Thank you!

@marcuslinke
Copy link
Contributor

@tejksat Sorry for being late but I don't get the intent of this PR. As I understood from your intitial comment on #624 the problem was that the current ByteBuf wasn't released properly. This could be easily fixed by calling current.discardReadBytes(). Could you explain please?

@tejksat
Copy link
Contributor Author

tejksat commented Sep 2, 2016

@marcuslinke there are several problems in the original code:

  • not releasing ByteBuf queued;
  • queuing ByteBuf until all data is read what effectively leads to OutOfDirectMemoryError if the data read is too big. This happens if you try to copy too big file or folder from a container. To fix this ResponseCallback (which in awaitResult() waits in fact for readComplete() channel method invocation) replaced with AsyncResultCallback;
  • actually queuing ByteBuf anyway leads to OutOfDirectMemoryError if data consumption is slower (the next point) than obtaining it;
  • poor performance because of the byte-by-byte reads.

/**
* Implementation of {@link ResultCallback} with the single result event expected.
*/
public class AsyncResultCallback<A_RES_T> implements ResultCallback<A_RES_T> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This special callback class should inherit ResultCallbackTemplate ideally and should be moved into InvocationBuilder internally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@tejksat tejksat force-pushed the fixHttpResponseInputStreamResourceLeak branch from bbda847 to aac58a7 Compare September 3, 2016 12:07
@marcuslinke
Copy link
Contributor

LGTM. Thanks @tejksat for fixing all these issues!

@marcuslinke marcuslinke merged commit 74d506d into docker-java:master Sep 5, 2016
@tejksat
Copy link
Contributor Author

tejksat commented Sep 5, 2016

@marcuslinke I'm glad to do that!

@tejksat tejksat deleted the fixHttpResponseInputStreamResourceLeak branch September 5, 2016 11:45
tejksat added a commit to tejksat/docker-java that referenced this pull request Sep 13, 2016
there are several problems in the original code:
- not releasing `ByteBuf` queued;
- queuing `ByteBuf` until all data is read what effectively leads to `OutOfDirectMemoryError` if the data read is too big. This happens if you try to copy too big file or folder from a container. To fix this `ResponseCallback` (which in `awaitResult()` waits in fact for `readComplete()` channel method invocation) replaced with `AsyncResultCallback`;
- actually queuing `ByteBuf` anyway leads to `OutOfDirectMemoryError` if data consumption is slower (the next point) than obtaining it;
- poor performance because of the byte-by-byte reads.
panuse pushed a commit to TuKangTech/docker-java that referenced this pull request Aug 20, 2017
there are several problems in the original code:
- not releasing `ByteBuf` queued;
- queuing `ByteBuf` until all data is read what effectively leads to `OutOfDirectMemoryError` if the data read is too big. This happens if you try to copy too big file or folder from a container. To fix this `ResponseCallback` (which in `awaitResult()` waits in fact for `readComplete()` channel method invocation) replaced with `AsyncResultCallback`;
- actually queuing `ByteBuf` anyway leads to `OutOfDirectMemoryError` if data consumption is slower (the next point) than obtaining it;
- poor performance because of the byte-by-byte reads.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants