Skip to content
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

SelectedSelectionKeySet.java throw UnsupportedOperationException #8242

Closed
monkey1993 opened this issue Aug 30, 2018 · 13 comments
Closed

SelectedSelectionKeySet.java throw UnsupportedOperationException #8242

monkey1993 opened this issue Aug 30, 2018 · 13 comments
Milestone

Comments

@monkey1993
Copy link

Expected behavior

When I use reflection to get a obejct that contains all fields, and then, I input it's info when I iterate it . But,I find an error that is UnsupportedOperationException

Actual behavior

Steps to reproduce

Minimal yet complete reproducer code (or URL to code)

class SelectedSelectionKeySet.java
at line 62

Netty version

4.1.27

JVM version (e.g. java -version)

8u172

OS version (e.g. uname -a)

win7

@normanmaurer
Copy link
Member

@monkey1993 please share the code that you used.

@monkey1993
Copy link
Author

No code. Just see SelectedSelectionKeySet.java at line 62

@normanmaurer
Copy link
Member

@monkey1993 sure but why you even access this SelectedSelectionKeySet ? I mean its internal and we not expose it at all.

@monkey1993
Copy link
Author

Reflection to get a object that contains all fields.Analyze memory footprin.

@monkey1993
Copy link
Author

Calculate each ChannelHandlerContext to occupy memory.

@normanmaurer
Copy link
Member

@monkey1993 I still dont get why you need this... just take an heap-dump and use a heap-dump analyser. I mean I can implement iterator but I am really not sure why you try to hand-roll this stuff.

@monkey1993
Copy link
Author

Calculate objects and their subobjects to occupy memory.

@normanmaurer
Copy link
Member

yeah and this is exactly what a heap-dump will give you and can be accessed via a heap-dump analyser like eclipse mat.

@monkey1993
Copy link
Author

like this

public class Session {
private ChannelHandlerContext ctx;
private long lastActiveTime;
private volatile boolean connect;
private volatile boolean isLogin;
private int sessionId;
}

Calculate this object to occupy memory.

@monkey1993
Copy link
Author

monkey1993 commented Aug 31, 2018

it's will be---> _make(8) + long(8) + int(4) + boolean(1) + boolean(1) + ref(4) + padding(6) = 32byte. But no ChannelHandlerContext object is calculated.

normanmaurer added a commit that referenced this issue Aug 31, 2018
… and remove(...)

Motivation:

Our SelectedSelectionKeySet does not correctly implement various methods which can be done without any performance overhead.

Modifications:

Implement iterator(), contains(...) and remove(...)

Result:

Related to #8242.
@normanmaurer
Copy link
Member

@monkey1993 while I still not understand why you bother handrolling a memory profiler I did the changes as it was trivial to fix:

#8244

PTAL

@monkey1993
Copy link
Author

I need to estimate the memory footprint of each object to make sure how many people my system can hold, and how it can expand when it expands.

@monkey1993
Copy link
Author

As you said, that's trivial, and I can still circumvent it to figure out how much memory an object occupies.

normanmaurer added a commit that referenced this issue Sep 1, 2018
… and remove(...) (#8244)

Motivation:

Our SelectedSelectionKeySet does not correctly implement various methods which can be done without any performance overhead.

Modifications:

Implement iterator(), contains(...) and remove(...)

Result:

Related to #8242.
@normanmaurer normanmaurer added this to the 4.1.30.Final milestone Sep 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants