Programming :: Pthread Not Release Memory
Jan 1, 2011
I have faced a problem with my code (a small tcp server). After the thread returns, the memory not decreases, but when a new connection is made, memory not increases and the new connection initialize a new thread with a same thread id of the previous thread. When two connections are made at same time, two thread ids are created and when the respective threads returns the memory not decreases. The Valgrind indicates that not memory leak occurs, the pointers are released. Indeed, more memory are allocate when new thread id is created. i used gcc and debian.
[Code]....
View 1 Replies
ADVERTISEMENT
Apr 19, 2010
I have an application that has pretty large memory profile. The general program flow is as follows:
Code:
main:
do 10 times:
[code]....
View 9 Replies
View Related
Jul 26, 2010
i have an application that launches several pthreads, i know that the default size used by Linux is 8Mb for each pthread. However i would like to optimize the total memory usage by my application by decreasing the default stack size of each pthread to the needed resources. My questions:
- Are there any rules to set the pthread stack size.
- How to compute the memory needed by each thread.
- Is the malloc call inside a thread counted from the stack size of the same pthread?
View 2 Replies
View Related
May 22, 2010
I wrote some code in c, using pthread (I configured the linker and compiler in eclipse IDE first).
Code: #include <pthread.h>
#include "starter.h"
#include "UI.h"
Page* MM;
[Code]....
View 6 Replies
View Related
Mar 12, 2011
I have created a pthread, and installed a signal handler inside that, same way as we do in main( ) function. The thread's signal handler is a separate function. Surprisingly, it is not working, that is the thread's signal handler is not able to catch signals. Here is the code:
Code: #include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <signal.h>
typedef struct data
[Code]...
View 1 Replies
View Related
Mar 10, 2011
im writing a cross-platform software (linux/solaris/mac/bsd) so i was wondering, how portable is pthread library? out of 10 linux distros, how many will have it by default? and does it exists on mac/solaris/bsd by default? or user will have to install it?
View 6 Replies
View Related
Dec 14, 2010
I want to suspend/resume a thread. The library I am using is pthread.h.I am also running my application on linux.Is there any function in pthread. let me suspend a thread temporary?I have read a document in which it was mentioned thatthread does not support suspend/resume
View 4 Replies
View Related
Aug 20, 2010
I'm trying to figure out how pthreads are mapped from the compiler to the Linux kernel. The pthread prototypes are found in a compiler header file (pthread.h), yet the kernel would be responsible for scheduling the threads. So, how does the compiler resolve the pthread symbols at compile time?
View 1 Replies
View Related
Jun 15, 2010
I am wondering if pthread could make that a single thread keeps the "mutex" all the time if the time it remains unlocked is very small.
thread1
{
while (1)
{
lock; do_task(); unlock();
[code]...
I experiment the thread2 never getting access to the mutex and never printing the nice message. I would expect that once thread2 calls "lock", it would get the mutex as soon as thread1 calls unlock() but it does not seem to be the case. If I add a sleep of some microseconds (100) in thread1 after unlocking the mutex, it solves the problem.
Does anyone know if this behaviour is normal? Is there a way to configure my mutex so that thread2 receives it when unlocked?I use
pthread_mutexattr_settype(&att, PTHREAD_MUTEX_RECURSIVE_NP);
pthread_mutex_init(&handle, &att);
to create my mutex. I am running ubuntu 9.04
View 3 Replies
View Related
Jan 12, 2011
I am working on a large program in C to run on Puppy Linux. I have multiple pthreads running. I want to be able to set the pthread SCHED_POLICY and priority in my program but I want a user to be able to run the program without root privilege.
Using a sticky bit and root ownership gives the user too much power because they will be able to write and compile their own scripts. Is there a way to use 'sudo' when I set the thread parameters from my program or something like this?
View 1 Replies
View Related
Sep 4, 2010
I have to compute prime numbers with threads in C. So I choose the algorithm "Sieve of Eratosthenes" and I tried to create 2 threads, but I don't know how to optimize my computing function with threads I beg for help. This is my function:
[Code]...
but it seems like the both of the threads are calculating the same function twice? Is it possible to be optimized or not?
View 7 Replies
View Related
Apr 19, 2010
I'm building a simple(?) socket server using threads to serve up a few requests. The spec is such that I have to listen to three ports at once, so I decided to use pthread to create three separate threads that would wait for connections, then spawn new threads to handle them.
The problem is that when I do this, for some reason the program never enters the wait loop and instead terminates (All three threads did get created since the messages get printed properly.) It gets to the line which prints "???", but not the line after the accept() call.I don't see an open port when I check for one either so I'm 99% sure they're terminating.Basically I have a main() method which has three calls to pthread_create, which should result in three threads being run that all wait for connections (listenOnPort). After each thread creation I print some info to make sure it's actually being created.
By the way, when I just run listenOnPortwithout threading, the server appears to enter the loop correctly and seems to be waiting for requests. It's only when I run the functions as threads that the problem seems to happen.The source is attached below. Any help will be appreciated. Much of the code is borrowed from a website (I can't post it because I am new here.) You need not worry about the handler_ methods because those are just methods that are run by the threads themselves.
Also--the original source was in C and I changed it to C++. Should I just use C?
server.h Code: /*
* server.h
[code]....
View 1 Replies
View Related
Mar 21, 2011
I am new to C and linux. My code below does arbitary writes but I cant figure out where or how it does it.
I am calling the insertNode() function with seq = 'MISSISSPPI$' and alphabets = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ$'
Code:
Weird behaviour I should mention is that when I check for NULL pointer in node->child[index], the unassigned values are not null anymore, they point to arbitary memory.
View 12 Replies
View Related
Apr 13, 2010
How do I write a script for my Linux that can show me total memory vs used memory and have it email me results if it's over 70 percent?
View 2 Replies
View Related
Aug 25, 2010
Is that possible that SHM shared memory is counted as cache memory on Linux with kernel 2.6.18?If find it really odd since this memory is not file backed, but I have a piece of code that loads data using shm_open+mmap, and it generates an amount of cache memory in /proc/meminfo that corresponds exactly to the amount of shared memory (I load that data from a file but I am using posix_fadvise(fd,0,0,POSIX_FADV_DONTNEED) to ensure this file is not cached and I made sure that it is working as expected). As far as I know SHM memory was not tagged as cache memory with kernel 2.6.9.If it is the case it is really unfortunate since normally cache memory can be considered to be part of the "available" memory since it can be flushed promptly but this is clearly not the case with SHM memory... Is there an easy way to get the total amount of used SHM memory on a system?
View 4 Replies
View Related
May 3, 2011
I've been trying to understand pthread in C a little better. So I made a simple program that takes in a string from the command line and creates a thread to print the string. I've looked online and copied the basic concepts but there are something things I'm confused about. The programs works just fine, but I have questions. Here's what I have so far.
[Code]....
One thing I'd like to know is why the 3rd argument in the pthread_create function which is my SendMessage function needs to be typecasted to a void pointer and then send the address of the function. Also as for the 4th argument, I would see typecasting to void pointer in some of the pthread examples I saw online, but in my case I'm passing a char pointer, would this be correct? In which case would I ever want to pass a void pointer?
Do I need a pthread_exit(NULL) in my main and in the SendMessage function? If so, why? I added the sleep() function so that I could let the pthread_exit function in my SendMessage function execute first. I simply saw that the online examples on pthread had pthread_exit() in both locations.
View 6 Replies
View Related
Mar 8, 2011
I have the following input:
Code:
Event 1............................................................
full_name: JENNY_JENNINGS genre: f
age: 32
[code]....
But as you can see in the input, in the 2nd "Event", the line containing "age" is not present, but in the output my code is printing the 1rst age value twice. The correct output should be blank in the age field for 2nd line in the output like this:
Code:
full_name|genre|age|code
JENNY_JENNINGS|f|32|15a
JOHN_JOHNSON|m||23c
MARY_JEAN|f|25|11d
What is wrong in my code? how can I fix it? * I�m using ubuntu 10.10
View 12 Replies
View Related
Jan 20, 2010
I have a C++ application consisting of several source/header files. As part of the release management procedure, I use a shell script to package all necessary sources/headers in a tar file for a successful compilation on end-user site.However, for example, each time a new directory is created within application's source tree, I need to edit the shell script to implement necessary changes, which is error-prone.What is the best practice to package the source/header files of an application into a tar file ? Is there any tool that I can use for packaging purposes rather than writing my own shell scripts ? For example, how is Linux kernel itself packaged into a tar file ?
View 2 Replies
View Related
May 6, 2010
After doing make I have the following questions? How can I see that the build is with debug information? What shall I do to build the release version? Can I have the release version in one directory and the debug version in another? I mean, when I change from debug to release, make will not overwrite the debug version.
View 7 Replies
View Related
Jan 8, 2010
I'm pretty new subversion, and have a basic question which I haven't found the answer to:Say that I on machine A modify the working copy of my code, create a tag "release-1.0", and commit it, how can I on machine B point the working copy to the tagged code? For example, say my "code" is actually config files for Apache, and I wan't apache running on machine B to update it's config files based on the files found in tag "release-1.0", how is this done?
I'm sure the solution is very easy, but I just can wrap my head around it.
View 2 Replies
View Related
Feb 9, 2011
release notes Flash Player 10.2 Release Notes
View 9 Replies
View Related
Dec 16, 2009
I have searched and found nothing.... I'm trying to install the DRI driver to make my RV200 ATI card work with 2d and 3d features. I am new to this linux world but I have probably read now 4 hours of installation procedures without fully knowing what I'm really doing.... (Some instructions assume too much from the knowledge of the user I think)... So I'm at the step where I,m building the libdrm (Step 1.3 from this procedure [URL] and I get the following error: checking for PTHREADSTUBS... configure: error: Package requirements (pthread-stubs) were not met: No package 'pthread-stubs' found
Now yum tells me that no package exists with such name. I have searched on google quite a bit and I really don<t know where to start digging at this point.
View 7 Replies
View Related
Jan 7, 2010
Where can i download pthread libraries for fedora12 pc kernel version 2.6.31.5-127.fc.12.i686?
View 3 Replies
View Related
Mar 31, 2010
I would like to know what is the difference between -lpthread, -pthread, -lthread? Sometimes, I have been used -lpthread as a option of gcc. but I don't understand anything about the others.
View 2 Replies
View Related
Mar 3, 2011
I'm currently developping a program in C++, using Qt, for an embedded board (SBC9261).It works well but crashes after some time, due to a system memory overload (my program uses more and more memory until 100%, when it crashes).I've been able to figure out the source of the memory leak :The function f is called by my program every second. f instanciates a new object (a QImage from the Qt lib), does a bunch of processing on it, and returns it to the calling function :
Code:
QImage *MyClass::f(QString filename) {// Open image
QImage *image = new QImage(filename);
[code]....
View 5 Replies
View Related
Jul 22, 2011
I have a general question regarding memory errors. I frequently ran into memory errors such as seg fault, double free, etc. Sometimes I got the following traces for example.
*** glibc detected *** /mnt/click: free(): invalid pointer: 0xb7ed8450 ***
======= Backtrace: =========
/lib/libc.so.6[0xb7dff905]
/lib/libc.so.6[0xb7e011a3]
[code]....
Then, I just run gdb, valgrind things and suddenly I started ask questions myself that what are those traces and how can I analyze?
View 1 Replies
View Related
Jan 11, 2009
i am wondering How to get usage of CPU, Memory in linux environment? So would you able to tell me the ways?
View 10 Replies
View Related
Aug 27, 2010
Can anyone please let me know of a link where I can find the source code for Linux pthread library?
View 2 Replies
View Related
Apr 19, 2010
I have 2 applications that send and receive messages through shared memory IPC. When I run the app ..it works but the number of messages per sec keeps changing drastically sometimes it is 400-500 per sec..then 800 then 1200 then 2000. is this normal with SHM IPC or could it be a code related issue.
View 9 Replies
View Related
Aug 23, 2010
Is there any program which gets the CPU and memory of a process ?
View 1 Replies
View Related