Sponsored Content
Full Discussion: Heap and stack
Top Forums Programming Heap and stack Post 302189809 by andryk on Monday 28th of April 2008 02:27:01 AM
Old 04-28-2008
Hi,
It'll be on stack i suppose and in general all variables declared inside a function will be on stack as well.
You can print the address of where a resides and print the value of stack pointer (SP) you then should have the same base address ...
Code:
unsigned long sp(void) {
   asm("movl %esp, %eax");
}
void main() {
  int *a;

  a=malloc(16*sizeof(int));
  printf ("addr of a is %p, sp is %p and malloc is %p\n",&a,sp(),a);
}

Of course i assume you're on intel-based Smilie!

Last edited by andryk; 04-28-2008 at 03:44 AM..
 

8 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

heap size!

I'm a new guy to this field and I'm learning a lot about UNIX! Can any explan to me what exactly does 'heap size' mean and how can i increase the size for AIX 4.3.3? (2 Replies)
Discussion started by: i2admin
2 Replies

2. Filesystems, Disks and Memory

heap size for JVM!

Hi all, Thanks 'thehoghunter' and 'hugo' for the comments! I've to increase the size of the heap size for AIX 4.3.3. Now what's the command that I've and also is it something similar to growing the file system in Solaris (growfs) (1 Reply)
Discussion started by: i2admin
1 Replies

3. AIX

AIX 5.3 Heap Memory with SAP

Any idea whether this parameter can be set / adjusted and where please? (3 Replies)
Discussion started by: johnf
3 Replies

4. Programming

what is stack winding and stack unwinding

helo can u tell me what do you mean by stack winding and stack unwinding Regards, Amit (2 Replies)
Discussion started by: amitpansuria
2 Replies

5. HP-UX

Heap fragementation on HPUX

The Resident size(as observed from top) of my process is increasing. But, the behaviour is very random. My process works on request reponse model. So when i put some request load on my process the memory starts increasing. For initial few hours (approx ~3 hrs) it increase at a rapid rate and after... (1 Reply)
Discussion started by: atgoel
1 Replies

6. HP-UX

Heap fragmentation on HPUX

Hi All, We are facing issues on HPUX with the C heap region growing. We use a product for CRM by name ClarifyCRM and it uses a native layer for DB access. so there are best practices in place to actual control memory. recently we have seen issues that the C heap region is growing faster than... (0 Replies)
Discussion started by: ramchand75
0 Replies

7. Programming

find size of heap allocated

I want to find the size of the total memory allocated on the heap for the following statement: int* a = new int;How can I use the sizeof operator for this? I used: printf("\t===> %d\n",sizeof(*a)); Is this statement correct? I have asked the question because when I checked the memory of... (13 Replies)
Discussion started by: rupeshkp728
13 Replies

8. UNIX for Dummies Questions & Answers

Kernel Stack vs User Mode Stack

Hi, I am new to the linux kernel development area. I want to know what is the difference between kernel mode stack and user mode stack? Does each process has a user mode stack and a kernel mode stack?? Or Each process has a user mode stack and there is only one kernel mode stack that is shared by... (4 Replies)
Discussion started by: saurabhkoar
4 Replies
Heap::Elem::StrRev(3pm) 				User Contributed Perl Documentation				   Heap::Elem::StrRev(3pm)

NAME
Heap::Elem::StrRev - Reversed String Heap Elements SYNOPSIS
use Heap::Elem::StrRev( StrRElem ); use Heap::Fibonacci; my $heap = Heap::Fibonacci->new; my $elem; foreach $i ( 'aa'..'bz' ) { $elem = StrRElem( $i ); $heap->add( $elem ); } while( defined( $elem = $heap->extract_top ) ) { print "Largest is ", $elem->val, " "; } DESCRIPTION
Heap::Elem::StrRev is used to wrap string values into an element that can be managed on a heap. The top of the heap will have the largest element still remaining. (See Heap::Elem::Str if you want the heap to always return the smallest element.) The details of the Elem interface are described in Heap::Elem. The details of using a Heap interface are described in Heap. AUTHOR
John Macdonald, john@perlwolf.com COPYRIGHT
Copyright 1998-2007, O'Reilly & Associates. This code is distributed under the same copyright terms as perl itself. SEE ALSO
Heap(3), Heap::Elem(3), Heap::Elem::Str(3). perl v5.8.8 2007-10-23 Heap::Elem::StrRev(3pm)
All times are GMT -4. The time now is 07:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy