Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
The class org.apache.http.pool.AbstractConnPool has this map field:
private final Map<T, RouteSpecificPool<T, C, E>> routeToPool;
If I use a lot of proxy ip, the map size will became bigger and bigger, this will cause oom.
How to solve it?
To be honest, I never had this issue working with an Apache HTP Client. Looking at your memory dump at Httpclient out of memory I see "104655 instances of class org.apache.http.pool.AbstractConnPool$1" which is an anon inner implementation of RouteSpecificPool which is the value type of the field you mentioned.
So the question is, how do you use the client? The connections have to be released at some point and unused and/or expired connections will be cleaned up.
Do never keep connections in the pool forever or do a keep alive for connections you do not use any more! Such things in combination with requests to high diverse targets (aka routes). You have to configure timeouts for usages (see also Apache Httpclient Connection not Released)!
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Why getText() in JPasswordField was deprecated?
According to this answer for the above question, what I understood was that creating a String object containing the password is a security threat because it may remain in the memory for a while and it is immutable.
So I was wondering,
How easy is it to retrieve something which has been hanging around
in the memory, without a reference or left out for garbage collection?
And how do you do it?
EDIT
As the question has been closed, be kind to share your knowledge by adding a comment, and consider reopening the question if you believe it may get interesting answers in the future. :)
https://en.wikipedia.org/wiki/Heartbleed
This is a good real-world example of things hanging in memory being used for exploitation. There's different ways to do it, so it's good to just make sure things that are valuable aren't being left hanging. Usually these attacks are just guess-and-check. You just keep sending information and piecing together the bits of extra memory you get in return.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a requirement where I am writing a small utility to test apis(ofcourse there are existing tools but it has been decided to write one). I am required to bombard the api, for the same api call, with say 100 threads, around say 100,000 times.
I am using 'PoolingHttpClientConnectionManager' for the making the calls. I am using something as mentioned in the below link:
https://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html
My question is:
(1) How can I run the above code for 100,000 iterations? Using that many number of threads is obviously a bad idea. Initially thought of using ExecutorService for maintaining thread count and number of jobs to be submitted but it felt redundant.
(2)I read about 'setMaxTotal'(max connections) and 'setDefaultMaxPerRoute'(concurrent connections) but I dont think it will help achieve(1) though I will obviously be required to increase the values.
Please advise. Thanks in advance.
You could use a threadpool and push the workerfunction the required number of times. Then you could even vary the number of workerthreads executing the functions to simulate different loadsituations.
Threadpool tutorial:
https://docs.oracle.com/javase/tutorial/essential/concurrency/pools.html
Why don't you use Jmeter for such performance/load testing?
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm coding a multithreading server. I got the server itself, many Client objects (each for every connection, in the Thread-Per-Client design) and one single Protocol instance. The Protocol object decides what do with every message the Client send.
I got ONE Protocol object, that many Client object can access, at the same time. The Protocol object got no variables of its own, but it access other objects.
My question is: Can it cause problem, that many clients are accessing the same object at the same time (giving the object got no variables)
If an object has no data, only methods, it's okay to access it in a multithreaded way. However, in your case, your Protocol object accesses other objects, so while your threads may not be sharing data in the Protocol object itself, they will be sharing those other objects and the data in them. Without proper synchronization, that can cause problems.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a question on recursion , what are the efficiencies and inefficiencies of recursion , I know it will use more memory but is it good to use it and when to use it?
It depends on the size of the objects you are recursing.
If you are doing recursion over objects that are already in memory, memory impact will be neglible because it's simply using the same objects that are already in memory over and over. Just see which objects/variables you can re-use to keep memory footprint low.
If you are recursing over directories/files etc.. and constantly loading stuff from disc or database that is not in memory yet, it can become very expensive to do so because of the loading, allocating and then processing.
It all depends on what you really are doing... and you haven't provided much detail.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How to set SO_LINGER socket option to ServerSocket? Should i extend SocketImpl class. But there are many abstract methods in SocketImpl class.
Set it on the Socket that you get from serverSocket.accept().
You can't set SO_LINGER on a ServerSocket. It doesn't make sense.
I'm wondering whether you even know what SO_LINGER is for. It is a very rarely used technique for enforcing a close timeout on connected TCP sockets, or, unfortunately, for forcing them to reset the connection when closed, which is an operation by far best avoided for many reasons, much-abused, and little understood.
You almost certainly don't want to use it at all on any socket whatsoever.