public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* memory allocation
@ 2013-09-16  8:43 zhaobin xv
  2013-09-17 14:45 ` Ian Lance Taylor
  0 siblings, 1 reply; 5+ messages in thread
From: zhaobin xv @ 2013-09-16  8:43 UTC (permalink / raw)
  To: gcc

Hi
As I know in C :
a. Global and static variables locate at data segment
b. When a function is called, memory is allocated on the stack to hold
parameter values, local variables, and the address of the calling
function
c. the struct is aligned based on the greatest alignment requirement
of it's members.
I want to know what these base on to define?
Are there some manual or book about these?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: memory allocation
  2013-09-16  8:43 memory allocation zhaobin xv
@ 2013-09-17 14:45 ` Ian Lance Taylor
  0 siblings, 0 replies; 5+ messages in thread
From: Ian Lance Taylor @ 2013-09-17 14:45 UTC (permalink / raw)
  To: zhaobin xv; +Cc: GCC Development

On Mon, Sep 16, 2013 at 1:43 AM, zhaobin xv <xvzhaobin@gmail.com> wrote:
>
> As I know in C :
> a. Global and static variables locate at data segment
> b. When a function is called, memory is allocated on the stack to hold
> parameter values, local variables, and the address of the calling
> function
> c. the struct is aligned based on the greatest alignment requirement
> of it's members.
> I want to know what these base on to define?
> Are there some manual or book about these?

This question is not appropriate for the mailing list gcc@gcc.gnu.org,
which is for the development of GCC itself.  It would be appropriate
for gcc-help@gcc.gnu.org.  Please take any followups to gcc-help.
Thanks.

The document you are looking for is generally called the ABI for the
target processor and operating system.  There are different ABIs for
each processor, and different operating systems on each processor also
have different ABIs.  If you tell us which specific processor and
operating system you are interested in we may be able to point you at
the ABI document for that target.

Ian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* re: memory allocation
@ 2003-09-13 16:34 Dan Kegel
  0 siblings, 0 replies; 5+ messages in thread
From: Dan Kegel @ 2003-09-13 16:34 UTC (permalink / raw)
  To: GCC Mailing List, gcc-help, laczo.tibor

Laczó Tibor wrote:
[ In Redhat Linux, how come calling delete on objects in C++
   doesn't return memory to the operating system?  Even after
   my program deletes all its big objects, RSS doesn't shrink. ]

That's an FAQ.  http://www.lysator.liu.se/c/c-faq/c-3.html says
Q. I have a program which mallocs but then frees a lot of memory,
but memory usage (as reported by ps) doesn't seem to go back down.
A. Most implementations of malloc/free do not return freed memory to
the operating system (if there is one), but merely make it available
for future malloc calls within the same process.

glibc's manual also mentions this:
http://www.gnu.org/manual/glibc-2.2.5/html_node/Freeing-after-Malloc.html#Freeing%20after%20Malloc
which says
"Occasionally, free can actually return memory to the operating system
and make the process smaller. Usually, all it can do is allow a
later call to malloc to reuse the space. In the meantime,
the space remains in your program as part of a free-list used internally by malloc."

Please take this discussion to gcc-help@gcc.gnu.org
or maybe comp.lang.c++.

gcc@gcc.gnu.org is for gcc maintainers, not users.
- Dan

-- 
Dan Kegel
http://www.kegel.com
http://counter.li.org/cgi-bin/runscript/display-person.cgi?user=78045

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: memory allocation
  2003-09-12 13:18 Laczó Tibor
@ 2003-09-12 13:21 ` Gerald Pfeifer
  0 siblings, 0 replies; 5+ messages in thread
From: Gerald Pfeifer @ 2003-09-12 13:21 UTC (permalink / raw)
  To: Laczó Tibor; +Cc: gcc, gcc-digest

On Fri, 12 Sep 2003, [iso-8859-2] Laczó Tibor wrote:
> What is the problem?

That you have used a list which is not appropriate for this kind of
questions.

This list is neither on programming, nor on the Linux kernel, nor
on the GNU/Linux system, but on the development _of_ (not _with_)
GCC.

Gerald
-- 
Gerald Pfeifer (Jerry)   gerald@pfeifer.com   http://www.pfeifer.com/gerald/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* memory allocation
@ 2003-09-12 13:18 Laczó Tibor
  2003-09-12 13:21 ` Gerald Pfeifer
  0 siblings, 1 reply; 5+ messages in thread
From: Laczó Tibor @ 2003-09-12 13:18 UTC (permalink / raw)
  To: gcc; +Cc: gcc-digest

Hi!

I use Redhat Linux.
I have made a C++ program that uses a lot of memory. In the program i 
have many objects. After the use of these object i use the 'delete' 
command to deallocate the memory used by them.

I monitor the program during its working with the 'TOP' command.
The RSS value increases to 500-600M. The program ends his Job, but it 
doesn't terminate, it is just in a pending status. But the RSS value is 
still 500-600M.
The big objects are deleted in the program under the pending status.

What is the problem?

thanks,
Tibor


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-09-17 14:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-16  8:43 memory allocation zhaobin xv
2013-09-17 14:45 ` Ian Lance Taylor
  -- strict thread matches above, loose matches on Subject: below --
2003-09-13 16:34 Dan Kegel
2003-09-12 13:18 Laczó Tibor
2003-09-12 13:21 ` Gerald Pfeifer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).