Sponsored Content
Top Forums UNIX for Advanced & Expert Users threads and memory allocation Post 92724 by prankster on Wednesday 14th of December 2005 09:14:33 AM
Old 12-14-2005
threads and memory allocation

Hello!
First of all, forgive me for bad English.

When I starts new thread (pthread_create), system allocates some memory for it (for example, for thread's stack). I wonder when does it deallocate this memory? The problem is that I have a program which sometimes creates new threads and sometimes deletes it. And memory used by my program always increases and never decreases (I use top utility to watch for my program behaviour). And I wonder is it my bug or standard behaviour. It seems my program stops threads which are not needed anymore, but memory doesn't decrease and after some time pthread_create says that it can't create new thread.

I will really appreciate your help!

P.S. The system is Solaris 5.10, if it matters.

Last edited by prankster; 12-14-2005 at 10:22 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

memory allocation

I would like to know how I could allocate some more memory to a process. Please note that I am not the root user. (1 Reply)
Discussion started by: sagar
1 Replies

2. UNIX for Dummies Questions & Answers

HP-UX memory usage allocation

Hi all, I have a HP-UX Server with 4 gigabytes of physical RAM. When I use the 'Glance' utility to see what my memory utilization is, my memory usage shows up maxed out at 99%. I shut off all the known processes that I'm running on that box and the memory utilization is still at 78% (with Swap... (1 Reply)
Discussion started by: dehuang83
1 Replies

3. Programming

Dynamic memory allocation

Hi, I am trying to process line by line of a file. But I should not be allocating static allocation for reading the contents of the file. The memory should be dynamically allocated. The confusion here is how do I determine the size of each line, put it into a buffer with the memory allocated... (11 Replies)
Discussion started by: naan
11 Replies

4. Programming

Memory allocation problem

I have a program that will fetch some particular lines and store it in a buffer for further operations.The code which is given below works but with some errors.I couldn't trace out the error.Can anybody help on this plz?? #include <stdio.h> #include <stdlib.h> #include<string.h> #define... (1 Reply)
Discussion started by: vigneshinbox
1 Replies

5. Programming

Is there a problem with the memory allocation???

I have a scenario like the client has to search for the active server.There will be many servers.But not all server are active.And at a time not more than one server will be active. The client will be in active state always i.e, it should always search for an active server until it gets one.I... (1 Reply)
Discussion started by: vigneshinbox
1 Replies

6. Programming

memory allocation in subroutine

Hi everyone, I'm not new to C programming, but I'm having question regarding the memory allocation of a pointer variable which, for instance, will be declared in main(), but its memory will be allocated in subroutine. To clearify my question, I provide a small working example: #include... (1 Reply)
Discussion started by: MIB_Maik
1 Replies

7. Programming

Memory allocation in C

Hi Experts I need some help in static memory allocation in C. I have a program in which I declared 2 variables, one char array and one integer. I was little surprised to see the addresses of the variables. First: int x; char a; printf("%u %u\n', &x, a); I got the addresses displayed... (2 Replies)
Discussion started by: unx_freak
2 Replies

8. Programming

memory allocation for string in C

hi in the following code, how the memory is allocated for a1 which holds the values of a2 after cpy function call. #include <stdio.h> #include <string.h> void cpy(char* d, const char* s){ while(*d++=*s++); } main(){ char* a1; char* a2="done"; cpy(a1,a2); ... (3 Replies)
Discussion started by: mprakasheee
3 Replies

9. Programming

C++/ROOT Memory Allocation?

Hello, I am new to C++ programming, so I'm still getting a feel for things. I recently wrote a simple C++ program (to be used as a ROOT Macro) to conduct a statistical analysis of a varied version of the Monty Hall problem (code below). Basically, the programs runs a few simple calculations to... (7 Replies)
Discussion started by: Tyler_92
7 Replies

10. UNIX for Dummies Questions & Answers

Memory allocation problem

I am using ubuntu. I have written a program to calculate prime factors. it works perfectly fine till entered number is less than 9989 (or so ) but when one enters a number higher than that, for example 15000, it does not work. Can anyone guide me whats the problem ? although new codes are welcome,... (2 Replies)
Discussion started by: Abhishek_kumar
2 Replies
pthread_attr_setguardsize(3)				     Library Functions Manual				      pthread_attr_setguardsize(3)

NAME
pthread_attr_setguardsize - Changes the guardsize attribute of the specified thread attributes object. LIBRARY
DECthreads POSIX 1003.1c Library (libpthread.so) SYNOPSIS
#include <pthread.h> int pthread_attr_setguardsize( pthread_attr_t *attr, size_t guardsize); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: IEEE Std 1003.1c-1995, POSIX System Application Program Interface PARAMETERS
Address of the thread attributes object whose guardsize attribute is to be modified. New value for the guardsize attribute of the thread attributes object specified by attr. DESCRIPTION
This routine uses the value specified in the guardsize argument to set the guardsize attribute of the thread attributes object specified in the attr argument. When creating a thread, use a thread attributes object to specify nondefault values for thread attributes. The guardsize attribute of a thread attributes object specifies the minimum size (in bytes) of the guard area for the stack of a new thread. A guard area, with its associated overflow warning area, can help a multithreaded program detect overflow of a thread's stack. A guard area is a region of no-access memory that DECthreads allocates at the overflow end of the thread's stack, following the thread's overflow warning area. If any thread attempts to write in the overflow warning area, a stack overflow exception occurs. Your program can catch this exception and continue processing as long as the thread does not attempt to write in the guard area. When any thread attempts to access a memory location within the guard area, a memory addressing violation occurs without the possibility of recovery. A new thread can be created with a default guardsize attribute value. This value is platform dependent, but will always be at least one "hardware protection unit" (that is, at least one page). For more information, see the platform-specific appendixes of Guide to DEC- threads. After this routine is called, due to platform-specific factors DECthreads might reserve a larger guard area for the new thread than was specified in the guardsize argument. For more information, see the platform-specific appendixes of Guide to DECthreads. DECthreads allows your program to specify the size of a thread stack's guard area for two reasons: When a thread allocates large data structures on its stack, a guard area with a size greater than the default size might be required to detect stack overflow. Overflow pro- tection of a thread's stack can potentially waste system resources, such as for an application that creates a large number of threads that will never overflow their stacks. Your multithreaded program can conserve system resources by "turning off" a thread's stack guard area--that is, by specifying a guardsize attribute of zero. If a thread is created using a thread attributes object whose stackaddr attribute is set (using the pthread_attr_setstackaddr(3) routine), this routine ignores the object's guardsize attribute and provides no thread stack guard area for the new thread. RETURN VALUES
If an error condition occurs, this routine returns an integer value indicating the type of error. Possible return values are as follows: Successful completion. The argument attr is not a valid thread attributes object, or the argument guardsize contains an invalid value. ERRORS
None RELATED INFORMATION
Functions: pthread_attr_init(3), pthread_attr_getguardsize(3), pthread_attr_setstacksize(3), pthread_create(3) Manuals: Guide to DECthreads and Programmer's Guide delim off pthread_attr_setguardsize(3)
All times are GMT -4. The time now is 04:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy