From mboxrd@z Thu Jan 1 00:00:00 1970 From: hwidjaja@my-deja.com To: help-gcc@gnu.org Subject: Re: Segmentation Fault: new char[12] Date: Wed, 08 Dec 1999 14:22:00 -0000 Message-id: <82mkqp$sac$1@nnrp1.deja.com> References: <82jp3a$pal$1@nnrp1.deja.com> <82kesh$994$1@nnrp1.deja.com> <82lqpm$7fo$1@nnrp1.deja.com> X-SW-Source: 1999-12/msg00124.html you can adjust the limit of your resource limit using setrlimit. Try man pages of getrlimit or setrlimit. to check the limit at the prompt, uses 'ulimit -a' (for ksh, zsh). i'm not sure about the other shells. hwidjaja In article < 82lqpm$7fo$1@nnrp1.deja.com >, atharaken@my-deja.com wrote: > Question: > > I use top to check the memory use. It does have a memory leak which I > need to fix but does Solaris have a limit on the amount of memory that > a application uses. It yes, how can that be changed. > > This computer has around 2GB of RAM and this is the only app running on > this machine apart from other system daemons etc.. > > In article < 82kesh$994$1@nnrp1.deja.com >, > hwidjaja@my-deja.com wrote: > > I didn't see problem at your code.. > > you mentioned that i gives a segm. fault when large number of users > > are accessing it ... > > I suspect that there is memory leaks in your code. Then you run out of > > memory... > > my suggestion is to check it, > > you can use 'top -U' or 'ps'. > > > > hwidjaja > > In article < 82jp3a$pal$1@nnrp1.deja.com >, > > atharaken@my-deja.com wrote: > > > This is a snippet of some code I am using. I get a Segmentation > Fault > > > in _smalloc (malloc). It works sometimes and when a large number of > > > users are accessing it gives a segmentation fault. > > > > > > It happens at the line: > > > > > > _string = new char [_capacity]; > > > > > > I call this using _Init(12); > > > This is a protected class. > > > > > > /* BEGIN CODE HERE */ > > > > > > bool MyClass::_Init (long size) > > > { > > > _capacity = size; > > > _string = new char [_capacity]; //Get Segmentation Fault at > > _smalloc > > > if (!_string) { > > > _capacity = _size = 0L; > > > return false; > > > } > > > _size = 0; > > > _string[0] = '\0'; > > > return true; > > > } > > > > > > /*END CODE HERE */ > > > > > > Machine: i386 > > > OS: Solaris 7 > > > GCC 2.95 (Release) > > > > > > Any help is appreciated > > > > > > Thanks > > > > > > Sent via Deja.com http://www.deja.com/ > > > Before you buy. > > > > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. > > > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From mboxrd@z Thu Jan 1 00:00:00 1970 From: hwidjaja@my-deja.com To: help-gcc@gnu.org Subject: Re: Segmentation Fault: new char[12] Date: Fri, 31 Dec 1999 22:24:00 -0000 Message-ID: <82mkqp$sac$1@nnrp1.deja.com> References: <82jp3a$pal$1@nnrp1.deja.com> <82kesh$994$1@nnrp1.deja.com> <82lqpm$7fo$1@nnrp1.deja.com> X-SW-Source: 1999-12n/msg00124.html Message-ID: <19991231222400.P88bxGxXFi2u48InufS-xzuABcnJMlP7wJP3aaCI4jM@z> you can adjust the limit of your resource limit using setrlimit. Try man pages of getrlimit or setrlimit. to check the limit at the prompt, uses 'ulimit -a' (for ksh, zsh). i'm not sure about the other shells. hwidjaja In article < 82lqpm$7fo$1@nnrp1.deja.com >, atharaken@my-deja.com wrote: > Question: > > I use top to check the memory use. It does have a memory leak which I > need to fix but does Solaris have a limit on the amount of memory that > a application uses. It yes, how can that be changed. > > This computer has around 2GB of RAM and this is the only app running on > this machine apart from other system daemons etc.. > > In article < 82kesh$994$1@nnrp1.deja.com >, > hwidjaja@my-deja.com wrote: > > I didn't see problem at your code.. > > you mentioned that i gives a segm. fault when large number of users > > are accessing it ... > > I suspect that there is memory leaks in your code. Then you run out of > > memory... > > my suggestion is to check it, > > you can use 'top -U' or 'ps'. > > > > hwidjaja > > In article < 82jp3a$pal$1@nnrp1.deja.com >, > > atharaken@my-deja.com wrote: > > > This is a snippet of some code I am using. I get a Segmentation > Fault > > > in _smalloc (malloc). It works sometimes and when a large number of > > > users are accessing it gives a segmentation fault. > > > > > > It happens at the line: > > > > > > _string = new char [_capacity]; > > > > > > I call this using _Init(12); > > > This is a protected class. > > > > > > /* BEGIN CODE HERE */ > > > > > > bool MyClass::_Init (long size) > > > { > > > _capacity = size; > > > _string = new char [_capacity]; //Get Segmentation Fault at > > _smalloc > > > if (!_string) { > > > _capacity = _size = 0L; > > > return false; > > > } > > > _size = 0; > > > _string[0] = '\0'; > > > return true; > > > } > > > > > > /*END CODE HERE */ > > > > > > Machine: i386 > > > OS: Solaris 7 > > > GCC 2.95 (Release) > > > > > > Any help is appreciated > > > > > > Thanks > > > > > > Sent via Deja.com http://www.deja.com/ > > > Before you buy. > > > > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. > > > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy.