Author Topic: Memory of Program and Heaps?  (Read 3692 times)

0 Members and 2 Guests are viewing this topic.

kryton9

  • Guest
Memory of Program and Heaps?
« on: September 16, 2013, 12:19:57 PM »
I am trying to get a better grasp of what is going on and saw in university computer science class video that a program is like this:

Memory space allocated to a program by the operating system:
+--------------------------------+
|             program code       |
+--------------------------------+
|                                |
|                                |
|                heap            |
|                                |
+--------------------------------+
|               stack            |
+--------------------------------+

And elsewhere to the operating system
there is a "far heap".

1. So in Oxygen when we use the keyword "new" does this use
the program's heap or the far heap?
1a. The video course showed the "near heap", the program's heap,
as what is used. If this is the case, then when and how is the far heap used?

2. Also, why doesn't Oxygen by default just
use "new" behind the scenes and create everything in the heap(dynamic memory)?


Charles Pegge

  • Guest
Re: Memory of Program and Heaps?
« Reply #1 on: September 16, 2013, 06:25:03 PM »
Hi Kent,

Oxygen currently uses the heap indirectly via oleStrings. I don't know how the heap used in the current process relates to the space used by other processes. It's a black box to me. You can use shared memory blocks, shareable with other processes, however. (Like sharing a file, but in memory.)

The stack should be the fastest memory available, since it sits in the CPU cache, but this is also a black-box area.

In addition to heap space, code space, and stack space there is also the pre-allocated program work space. This is for globals, statics, import/export tables, and various other sections loaded from a binary file.

kryton9

  • Guest
Re: Memory of Program and Heaps?
« Reply #2 on: September 16, 2013, 09:51:46 PM »
Thanks Charles. In doing further research tonight it seems each compiler could have its own way of where it puts things too, so too daunting for me to go much deeper into this stuff.

I was trying to figure out how to pass an oxygen class to a dll created by c++ to access stl containers. Apparently the only container you can do this way is vectors, all the other containers will not allow it.

The next option is to write stuff in c using a void pointer and see if I can get anything to happen. Still researching, no test code yet.

Charles Pegge

  • Guest
Re: Memory of Program and Heaps?
« Reply #3 on: September 18, 2013, 01:06:21 PM »
I'm not familiar with STL containers. Are they for standard storage and retrieval of data?

http://msdn.microsoft.com/en-us/library/1fe2x6kt.aspx

Looks useful for making compilers :)

kryton9

  • Guest
Re: Memory of Program and Heaps?
« Reply #4 on: September 18, 2013, 04:56:15 PM »
Yes, they are almost every data storage container system  that is useful and also algorithms to make use of them.
The iterations process code has really been cleaned up in c++11 too, so it is even easier to use and be useful.

I have been going over c books online to refresh my memory, and it is just too hard to go back to it after c++, especially c++11.