🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #9258

Re: Thread and memory

#9258
From: Bob Gonder
Date: Tue, 20 Jul 2004 20:49
32 lines
2571 bytes
Sara T. wrote:

>Although I call a lot of times as following:
>
>1: for (int i=0; i<Queue->Count(); i++) {
>2:   CMyThread *MyThread = new MyThread();
>3:   MyThread->Resume();
>4: } /* for */

That seems bad to me. This is a server, right?
What happens to the number of running threads if requests come in
faster than the database can process them?
How many thousands of threads can the server handle without slowing
down, and making the problem worse?

I would think that maybe you should create a fixed number of threads
(it could be determined at runtime by a setting made by the sysop)
Each thread would look in a (thread-safe) FIFO queue for it's next
assignment.  The main app would add assignments to the FIFO.
That way, throughput is limited by the number of threads, but doesn't
degrade to nothing under heavy demand.
If number of threads is configurable, the throughput can be optimized
to fit the server and database speeds.

>I observe again and fould usually Virtual Memory has nerver been decreased.
>it takes 500MB and adding a Physical Memory 350 MB, that's all around 1GB.
>It makes a resource of the machine unusually and found the error "Thread
>creation error: Not enough storage is available to process this command"

Hmmm.. You have a Sleep(200) after update database, but before
termination.
How many more threads have you started while that thread is sleeping?
Technical Details
Message-ID: <u40rf05v2pj1pbah8j3l3pc68h0trirkcj@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!news.zanker.org!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40fb3d08@newsgroups.borland.com> <40fbf87b$1@newsgroups.borland.com> <40fbfd74$1@newsgroups.borland.com> <40fc1022$1@newsgroups.borland.com> <40fcab00@newsgroups.borland.com> <40fcb75c$1@newsgroups.borland.com> <40fcc5b3@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,d35c53850c011fac
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Thread and memory
Date: Tue, 20 Jul 2004 13:49:52 -0700
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <u40rf05v2pj1pbah8j3l3pc68h0trirkcj@4ax.com>
References: <40fb3d08@newsgroups.borland.com> <40fbf87b$1@newsgroups.borland.com> <40fbfd74$1@newsgroups.borland.com> <40fc1022$1@newsgroups.borland.com> <40fcab00@newsgroups.borland.com> <40fcb75c$1@newsgroups.borland.com> <40fcc5b3@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 65.41.125.111
X-Trace: newsgroups.borland.com 1090356589 65.41.125.111 (20 Jul 2004 13:49:49 -0700)
Lines: 38
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!news.zanker.org!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail