|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
System.OutOfMemory exception errorHi,
I have created a socket application which is connected at both the end. It receives messages from Server and sends it to its connected clients. I receive System.OutOfMemory exception error in the statement "Thread.Start(Args())". Whenever a messages comes in to this process, a thread is created to send that message out to clients. Since its a market price feed messages, number of messages comes for a sec. Is this error occurs due to the higher number of threads running in a system? Can anyone explain me how to fix this Memory error or a way to manage the threads? -- Regards Valli Hi, Vali
It seems each thread consumes too much memory or too many threads coming inside The proposal is following 1) estimate how much memory consumes each thread 2) before running new thread retrieve amount of memory still available 3) if there is still enough memory according to your criteria run the thread 4) otherwise postpone the tread (store incoming message in collection or somewhere else (temporary File?)) for a later run Do you have another ideas? By the way check for memory leaks within thread. Regards, Jamal Show quoteHide quote "Valli" <va***@chellsoft.com> wrote in message news:%23ltY7gg$JHA.1252@TK2MSFTNGP04.phx.gbl... > Hi, > > I have created a socket application which is connected at both the end. It > receives messages from Server and sends it to its connected clients. > I receive System.OutOfMemory exception error in the statement > "Thread.Start(Args())". > > Whenever a messages comes in to this process, a thread is created to send > that message out to clients. Since its a market price feed messages, > number of messages comes for a sec. Is this error occurs due to the higher > number of threads running in a system? > > Can anyone explain me how to fix this Memory error or a way to manage the > threads? > > -- > Regards > Valli > Hi,
Thanks for your suggestions. The memory consumption error occurs since the thread takes time to close. The thread performs a write operation in a file. Synclock is applied on that file. So the thread waits until the lock release. All the threads waits to perform this write operation & therefore the thread count also increases. This provided memory error. I have decided to use thread pool concept now. -- Show quoteHide quoteRegards Valli "Jamal" <samed***@planet.nl> wrote in message news:OdghUPk$JHA.3732@TK2MSFTNGP02.phx.gbl... > Hi, Vali > > It seems each thread consumes too much memory or too many threads coming > inside > > > > The proposal is following > > 1) estimate how much memory consumes each thread > > 2) before running new thread retrieve amount of memory still available > > 3) if there is still enough memory according to your criteria run the > thread > > 4) otherwise postpone the tread (store incoming message in collection or > somewhere else (temporary File?)) for a later run > > > > Do you have another ideas? > > > > By the way check for memory leaks within thread. > > > > Regards, Jamal > > "Valli" <va***@chellsoft.com> wrote in message > news:%23ltY7gg$JHA.1252@TK2MSFTNGP04.phx.gbl... >> Hi, >> >> I have created a socket application which is connected at both the end. >> It receives messages from Server and sends it to its connected clients. >> I receive System.OutOfMemory exception error in the statement >> "Thread.Start(Args())". >> >> Whenever a messages comes in to this process, a thread is created to send >> that message out to clients. Since its a market price feed messages, >> number of messages comes for a sec. Is this error occurs due to the >> higher number of threads running in a system? >> >> Can anyone explain me how to fix this Memory error or a way to manage the >> threads? >> >> -- >> Regards >> Valli >> > > On 2009-07-06, Valli <va***@chellsoft.com> wrote:
> Hi, You've most likely created to many threads... Each thread allocates a fixed> > I have created a socket application which is connected at both the end. It > receives messages from Server and sends it to its connected clients. > I receive System.OutOfMemory exception error in the statement > "Thread.Start(Args())". > amount of stack space from the application stack. My suggestion to you is to abandon explicit threads and move your sockets to async. The reason for this is taht the async socket functions make use of the windows iocompletion port facility. This gives much greater scalability then using explicit threading.... -- Tom Shelton
structures in VB.Net
Detect scroll in a ListView OpenFileDialog and ApplicationSettings (FileName) Problem with System.Drawing.Bitmap() Excel interop. Choose version of Excel to launch Application Help (i.e. Help Class) Addin to trap email item open Encrytion Component How to Get a URL from a Shortcut in Favorites HD Monitor |
|||||||||||||||||||||||