public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Determining Physical and Virtual Memory At Runtime In C
@ 2006-04-14 15:41 Jonathan Schreiter
  2006-04-14 16:32 ` zippo
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Schreiter @ 2006-04-14 15:41 UTC (permalink / raw)
  To: gcc-help

Hi,
Can anyone point me in the direction on a relatively
simple way to determine the amount of physical memory
and virtual memory available on a system at runtime? 
I'd like to be able to determine each value
independently, not the sum of both (total available
memory).  

I'd like to differentiate between the two in a c
program (gcc 4) in x86_64 linux (although that
shouldn't matter).  

Memalloc works fine, but performance slows down if
large arrays allocate in the upper paging file memory.
 I'd like to be able to split up calculations relative
to the available memory results returned.

Any help would be greatly appreciated.

Thanks,
Jonathan

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

* Re: Determining Physical and Virtual Memory At Runtime In C
  2006-04-14 15:41 Determining Physical and Virtual Memory At Runtime In C Jonathan Schreiter
@ 2006-04-14 16:32 ` zippo
  2006-04-14 17:05   ` Jonathan Schreiter
  0 siblings, 1 reply; 4+ messages in thread
From: zippo @ 2006-04-14 16:32 UTC (permalink / raw)
  To: gcc-help

$top all you need and more

On Fri, 14 Apr 2006 08:41:39 -0700 (PDT)
Jonathan Schreiter <jonathanschreiter@yahoo.com> wrote:

> Hi,
> Can anyone point me in the direction on a relatively
> simple way to determine the amount of physical memory
> and virtual memory available on a system at runtime? 
> I'd like to be able to determine each value
> independently, not the sum of both (total available
> memory).  
> 
> I'd like to differentiate between the two in a c
> program (gcc 4) in x86_64 linux (although that
> shouldn't matter).  
> 
> Memalloc works fine, but performance slows down if
> large arrays allocate in the upper paging file memory.
>  I'd like to be able to split up calculations relative
> to the available memory results returned.
> 
> Any help would be greatly appreciated.
> 
> Thanks,
> Jonathan
> 

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

* Re: Determining Physical and Virtual Memory At Runtime In C
  2006-04-14 16:32 ` zippo
@ 2006-04-14 17:05   ` Jonathan Schreiter
  2006-04-14 17:11     ` Brian Dessent
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Schreiter @ 2006-04-14 17:05 UTC (permalink / raw)
  To: zippo, gcc-help

Thanks for the reply, but I'm looking for a way to
programmatically determine the memory from inside the
C program.  I suppose one could execute a shell
statement and bring that data back in to C, but I'd
like a simpler approach that does not rely on top.  Am
I perhaps missing something?

Jonathan

--- zippo <zippo752001@comcast.net> wrote:

> $top all you need and more
> 
> On Fri, 14 Apr 2006 08:41:39 -0700 (PDT)
> Jonathan Schreiter <jonathanschreiter@yahoo.com>
> wrote:
> 
> > Hi,
> > Can anyone point me in the direction on a
> relatively
> > simple way to determine the amount of physical
> memory
> > and virtual memory available on a system at
> runtime? 
> > I'd like to be able to determine each value
> > independently, not the sum of both (total
> available
> > memory).  
> > 
> > I'd like to differentiate between the two in a c
> > program (gcc 4) in x86_64 linux (although that
> > shouldn't matter).  
> > 
> > Memalloc works fine, but performance slows down if
> > large arrays allocate in the upper paging file
> memory.
> >  I'd like to be able to split up calculations
> relative
> > to the available memory results returned.
> > 
> > Any help would be greatly appreciated.
> > 
> > Thanks,
> > Jonathan
> > 
> 

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

* Re: Determining Physical and Virtual Memory At Runtime In C
  2006-04-14 17:05   ` Jonathan Schreiter
@ 2006-04-14 17:11     ` Brian Dessent
  0 siblings, 0 replies; 4+ messages in thread
From: Brian Dessent @ 2006-04-14 17:11 UTC (permalink / raw)
  To: gcc-help

Jonathan Schreiter wrote:

> Thanks for the reply, but I'm looking for a way to
> programmatically determine the memory from inside the
> C program.  I suppose one could execute a shell
> statement and bring that data back in to C, but I'd
> like a simpler approach that does not rely on top.  Am
> I perhaps missing something?

You're asking on the wrong place.  This has nothing to do with gcc
itself.  It is target/platform specific.  On linux you can just open()
the appropriate file under /proc and read the values.  But that is not
going to be very portable.

Brian

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

end of thread, other threads:[~2006-04-14 17:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-14 15:41 Determining Physical and Virtual Memory At Runtime In C Jonathan Schreiter
2006-04-14 16:32 ` zippo
2006-04-14 17:05   ` Jonathan Schreiter
2006-04-14 17:11     ` Brian Dessent

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).