Re: More threads



On Tue, Dec 06, 2005 at 06:33:31PM +0800, David Xu wrote:
> Michael Vince wrote:
[...]
> >But I just can't seem to get past that mark, I have a lot of memory
> >currently the Tomcat is allocated 2gigs of memory.
[...]
> Number of threads you can create if you use libthr is limited by
> following factors:
> 1) sysctl:
> kern.threads.max_threads_per_proc
> kern.threads.max_groups_per_proc
>
> 2) stack
> per-thread userland stack, default number on 64 bits platform is 2M,
> on 32 bits platform, it is 1M. I don't know whether java supports
> adjusting default per-thread stack size. if can not, we may add
> an environment variable to thread libraries, for example:
> LIBPTHREAD_THREAD_STACKSIZE allows user to set default stack size.
>
> Thread also needs a kernel mode stack when it is in kernel, if
> I am right, it is 16K bytes per-thread. if you create too many
> threads, make sure both side won't exhaust address space, and
> because kernel stack can not be swapped out when process is
> running, you'd make sure physical memory can not be exhausted.
>
> 3) check memory limits
> type limits command:
>
> Resource limits (current):
> cputime infinity secs
> filesize infinity kB
> datasize 524288 kB
> stacksize 65536 kB
> coredumpsize infinity kB
> memoryuse infinity kB
> memorylocked infinity kB
> maxprocesses 5547
> openfiles 11095
> sbsize infinity bytes
> vmemoryuse infinity kB
>
> if address space is not large enough, you have to reconfigure kernel
> to allow larger space. Fix me if I am wrong.

I think that Michael's real problem is the amount of memory he has
allocated. If he has 2GB allocated already then he is out of luck if
he needs to allocate more (e.g. to create another thread). See mmap(2),
particularly the BUGS section.

--
Greg Lewis Email : glewis@xxxxxxxxxxxxxx
Eyes Beyond Web : http://www.eyesbeyond.com
Information Technology FreeBSD : glewis@xxxxxxxxxxx
_______________________________________________
freebsd-performance@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-performance
To unsubscribe, send any mail to "freebsd-performance-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: run-time vs compile-time
    ... > offset related to some location (like stack base) somewhere. ... > offset from heap to pi. ... When you allocate an int on the heap, it is allocated at address 1. ... application has a given amount of memory it can use as it wishes. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: run-time vs compile-time
    ... > offset related to some location (like stack base) somewhere. ... > offset from heap to pi. ... When you allocate an int on the heap, it is allocated at address 1. ... application has a given amount of memory it can use as it wishes. ...
    (comp.lang.cpp)
  • Re: Doubt on Stack variables.
    ... Will it allocate memory for all the char's together or allocate for ... this only second char in the function gets memory. ... As other posters have pointed out, the notion of a "stack" does not appear ... the stack limits) would run into these limits. ...
    (comp.lang.c)
  • Re: Sharing memory between kernelspace and userspace
    ... deallocate, on a totally dynamic basis, userspace ... Let userspace allocate shared memory visible to multiple ... and pass that into the kernel for it to write to. ...
    (Linux-Kernel)
  • Re: style question,itoa
    ... able to allocate buffers in some convenient location the callee ... dynamically allocate a block of memory and computing this size to use ... call might require allocating a page for the stack. ... " Checking every single malloc in a bigger application for possible ...
    (comp.unix.programmer)