Thread and memory consumption

  • Thread starter Thread starter Marty
  • Start date Start date
M

Marty

Hi,

Does anybody is experiencing a lot of RAM consumption when using many
threads ?

If yes, how can we reduce that level of used memory?

Thanks tou!
Marty
 
Use less threads? Reduce the amount of allocations each thread is doing?

It all depends on what resources your threads are using. Presumably they
aren't just idling ;)
 
Hi Robin,

I run a thread in an object (named myQueue) that raise an event for
every item within a queue. So it is an object that empty a queue of
pending messages.

That object, myQueue, is used in a server that accept up to 50
concurrent client connection, each connection having its own myQueue.
Each client sends messages to the server and message are queued in the
client's myQueue.

The thread will sleep for 10 milliseconds when it finish an iteration of
its queue.

This is very low on ressources (it use only a queue in each thread) and
I was wondering if using such threads would be the reason for a high
memory usage. Does microsoft document the consumption of a single
thread, just idling? How could I quantify it without looking in the task
manager?

Thanks,
Marty
 
Why do you queue the messages? How did you setup your server? Does each
client have its own socket?
 
ok, the server has a socket listener that listen for potential clients.
When a client connect to the server, the server assign a socket for
that new client and continue to listen for other clients.

When the server connect the client, it create also a myQueue that I
explained previously. The client begin to send messages to the server,
when messages are received on the server side, they are queued in
myQueue, then unqueued to be processed. The queue is used to have a
smoother execution, so I don't have to allocate a big buffer for the
socket incoming data.

So each clients has its own queue in the server.

Any idea if that number of threads could increase memory usage?
 
50 threads is way too much. You should have one thread that processes the
incoming data from all the clients and not a thread for each one. When the
data arrives you should place it in a class wide Queue or and ArrayList.
 
Why 50 thread would be too much? They do not perform a lot of work,
mostly idling, and ponctually performing clients requests.

I know that in process automation, systems can handles more than 1000s
of threads (in C++) and system are very reliables.

How can I quantify the ratio threads/memory and CPU to have a good and
fast execution?

Do you have any web references?

Thanks very much!
Marty
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top