Heap and RAM

Heap and RAM

Page 1 of 1

7 Replies - 4889 Views - Last Post: 26 May 2008 - 10:51 AM Rate Topic: -----

#1 srishekh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 29-September 06

Heap and RAM

Post icon  Posted 20 May 2008 - 09:35 PM

Hi All,

I want a clarification regarding heap and RAM memory .
Is Heap memory is part of RAM?
Can we allocate a dynamic memory using new, which is more than RAM size?
Please clarify.
Thanks and regards
shekhar
Is This A Good Question/Topic? 0
  • +

Replies To: Heap and RAM

#2 Cerolobo  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 52
  • View blog
  • Posts: 450
  • Joined: 05-April 08

Re: Heap and RAM

Posted 20 May 2008 - 09:39 PM

View Postsrishekh, on 20 May, 2008 - 09:35 PM, said:

Is Heap memory is part of RAM?

Yes and no. The heap includes your RAM, as well as any additional virtual memory your OS allocates.

View Postsrishekh, on 20 May, 2008 - 09:35 PM, said:

Can we allocate a dynamic memory using new, which is more than RAM size?

This really depends.Yes, you can allocate more memory then the amount of RAM you have, as long as there enough continuous virtual memory.
Was This Post Helpful? 0
  • +
  • -

#3 pesadilla143  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 21-May 08

Re: Heap and RAM

Posted 21 May 2008 - 01:44 AM

WOW... you are GOOD. You went from beginner to intermediate programmer within 40 minutes. Good job :)

-according to both of your posts-
Was This Post Helpful? 0
  • +
  • -

#4 srishekh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 29-September 06

Re: Heap and RAM

Posted 21 May 2008 - 03:18 AM

View PostCerolobo, on 20 May, 2008 - 09:39 PM, said:

View Postsrishekh, on 20 May, 2008 - 09:35 PM, said:

Is Heap memory is part of RAM?

Yes and no. The heap includes your RAM, as well as any additional virtual memory your OS allocates.

View Postsrishekh, on 20 May, 2008 - 09:35 PM, said:

Can we allocate a dynamic memory using new, which is more than RAM size?

This really depends.Yes, you can allocate more memory then the amount of RAM you have, as long as there enough continuous virtual memory.

Thanks
How do I know how much virtual memory i have ?
Was This Post Helpful? 0
  • +
  • -

#5 KYA  Icon User is online

  • Wubba lubba dub dub!
  • member icon

Reputation: 3199
  • View blog
  • Posts: 19,230
  • Joined: 14-September 07

Re: Heap and RAM

Posted 21 May 2008 - 06:04 AM

View Postpesadilla143, on 21 May, 2008 - 02:44 AM, said:

WOW... you are GOOD. You went from beginner to intermediate programmer within 40 minutes. Good job :)

-according to both of your posts-


????
Was This Post Helpful? 0
  • +
  • -

#6 mikeblas  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 44
  • View blog
  • Posts: 390
  • Joined: 08-February 08

Re: Heap and RAM

Posted 21 May 2008 - 06:23 AM

View Postsrishekh, on 21 May, 2008 - 03:18 AM, said:

How do I know how much virtual memory i have ?
That will depend on your OS. On Windows, you can call GlobalMemoryStatusEx() to get information about the memory subsystem. This will tell you how much virtual memory is available, but won't tell you how much contiguous VM space you have.
Was This Post Helpful? 0
  • +
  • -

#7 srishekh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 29-September 06

Re: Heap and RAM

Posted 26 May 2008 - 02:54 AM

thanks a lot
Was This Post Helpful? 0
  • +
  • -

#8 perfectly.insane  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 70
  • View blog
  • Posts: 644
  • Joined: 22-March 08

Re: Heap and RAM

Posted 26 May 2008 - 10:51 AM

View Postsrishekh, on 20 May, 2008 - 09:35 PM, said:

Can we allocate a dynamic memory using new, which is more than RAM size?


Technically, you could... but that is dependent on some factors.

1.) On 32-bit windows, the address space is limited to 2GB, and 3GB if you set a special option in %SYSTEMDRIVE%\boot.ini. You can't go beyond that for a single process. (Except using address windowing extensions, which you won't be able to do using the new operator). You can use a technique that involves the CreateFileMapping/MapViewOfFile calls to get around this. But even in that case, you're still limited to accessing 2GB at a time. (On linux, I belive this is also configurable when you build the kernel).

2.) If you're knowingly going to allocate this much memory, then a specialized solution is likely to be more appropriate. I don't think most OS's will actually manipulate VM swapped to disk directly on the disk itself. They swap the memory back to physical memory first in order to work with the requested memory. This will destroy a system's performance and will likely cause all other applications to be very unresponsive.
Was This Post Helpful? 1

Page 1 of 1