Re: Memory usage on Win32: Euphoria usage vs. what Task Manager displays

new topic     » goto parent     » topic index » view thread      » older message » newer message
CladStone said...

Maybe I'm just worried/curious about stuff that doesn't matter, but in the interest of "running a tight ship", I'm trying to figure out why what I see in Windows Task Manager doesn't seem to match up with what I would expect, so I'm wondering if someone could explain to me some basics of how Euphoria uses and releases memory, and how I can "force" it to take it or give it back, etc.

I realize that part of the issue may have to do with the way Task Manager reports memory usage, so any insights on that would help too.

A few examples:

1) I have some code where I explicitly allocate 32 MB of memory, but it doesn't show up in Task Manager. Does Task Manager not show you allocated memory, but rather only what is actually being used of that allocated memory?

2) I have another bit of code that loads a file and does some work with it. When I'm done, I want to be able to free up the extra space, so I say: mybigvar = {}. The first such statement produces NO effect whatsoever in Task Manager. The second such statement (e.g. myotherbigvar = {}) produces a small decrease (a couple hundred KB) which is well under the size of either of these variables.

3) Same example as #2, but with memory, not sequences. The file data itself was in a memory buffer, which I free, but doing so produces NO corresponding effect in Task Manager, though I'd expect to see a drop of about 500 KB.

I will only comment on #1. The others deal with Euphoria internals and there are others much better qualified to answer.

Windows, along with Linux and the Mac (OSX and later), uses a virtual mmeory system. Each application is given a 4GB virtual address space that is completely independent of physical memory size. The upper 2GB is common to all processes and the lower is private to each process. That is the default for Windows, other systems may vary. Applications never allocate or access physical memory directly. Physical memory resoureces are managed by the system.

When any application allocates memory it is actually allocating virtual address space. How much of this space will actually be populated with RAM is entirely up to the system. Many factors are considered, such as how the virtual address space is accessed, how much memory is available in the system, and the requirements of other processes. When RAM is assigned to a process it is the system that determines how long it gets to keep it, not the application. Applications can influence this to a degree but not control it.

Applications are never aware of any of this.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu