Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] OutOfMemoryError

Thanks Simone.

I will have a try later.

The error is because I just create many clients so the thread pool is filled

2015-09-21 15:42 GMT+08:00 Simone Bordet <sbordet@xxxxxxxxxxx>:

On Mon, Sep 21, 2015 at 9:14 AM, Muhui Jiang <jiangmuhui@xxxxxxxxx> wrote:
> Hi,
> But before send request, we have do the things below.
>         FuturePromise<Session> sessionPromise = new FuturePromise<>();
>         client.connect(sslContextFactory, new InetSocketAddress(host, port),
> new ServerSessionListener.Adapter(), sessionPromise);
>         Session session = sessionPromise.get(5, TimeUnit.SECONDS);
>         HttpFields requestFields = new HttpFields();
>         requestFields.put("User-Agent", client.getClass().getName() + "/" +
> Jetty.VERSION);
>         MetaData.Request metaData = new MetaData.Request("GET", new
> HttpURI("https://"+host+":"+port+"/"), HttpVersion.HTTP_2, requestFields);
>         HeadersFrame headersFrame = new HeadersFrame(0, metaData, null,
> true);
>     then we can make the request:
> stream(.....)
> If I have a array contains 10000sites. for example websites[10000];
> Which things should be done 10000 times?
> I have tried to start client once only. but I still failed.

HTTP2Client is very low level if you want to do a web bot.
Does not do connection pooling, does not do async DNS lookup, etc.

In any case, if you just have to send a single request for each
website, what you have to do is:

for each website

Each of those 3 operations is async, so you have to wait for each one
to complete (via callbacks) before issuing the next operation.
You can do them in parallel.

The error:

java.lang.OutOfMemoryError: unable to create new native thread

is likely due to a misconfiguration of your OS or thread pool.

Simone Bordet
Developer advice, training, services and support
from the Jetty & CometD experts.
jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top