Allocating RAM in OSX

I would like to overide the osx ram allocator
and allocate 700000 ram to a specific application.
can it be done?

It can’t be done because it doesn’t need to be done.

All applications under Mac OS X have the full amount of RAM available to them - at least as far as they are concerned. You do not need to artificially limit applications.

The OS will automatically make available however much memory your app needs. If it needs 1MB it will get 1MB, if it needs 1GB it’ll get 1GB (although probably via some combination of virtual and real memory).

Furthermore, there is no advantage in ‘allocating’ more memory to your app than it needs. The memory would just be wasted.

That was always the problem with pre-X memory allocations - if you allocate 90% of the available memory to your app, you can’t launch any others because there’s no free RAM available, even though your app may be using 1% (or less) of that allocation.

In summary, leave it to the OS.

you could have just written that you didn’t know how.

And you could stop reading after “It can’t be done” :wink:

Sheesh, did you actually read my post?

It’s not a matter of knowing or not. It’s a matter of wasting your time trying because a) there is no direct way of doing what you request, and b) it wouldn’t do any good even if you did.

For example, if you really, really want your app to consume 700MB of RAM when it starts up, do something like:

 on run
   set wasteOfTime to ""
   repeat (700 * 1024 * 1024) times
      copy "a" to end of wasteOfTime
   end repeat

This will make a 700MB string for which the OS will allocate your application 700MB of RAM to hold it. Bingo. Your app is now using 700MB of RAM.

However, this RAM is now locked to this useless object so you’re going to have trouble running other applications, but I warned you about that.

Of course, once you’ve got your 700MB of RAM you could just reset the object to an empty string:

set wasteOfTime to ""

but now (at least conceptually), the OS will now recognize the 700MB as free and will start to allocate it to other applications that need it more.

So, like I said, leave it to the OS. It can usually handle this kind of thing better than you can.

ok, im sorry for being a “prick”.
but, I just don’t understand why the application , which was originally
written for a pc and “ported”,(ported is a 4 letter word to me), to mac
can’t run better. It’s Ghost Recon. It opens multiple files for sound
textures, bit maps, action files, effect files and so on. The texture files
alone would fill up 200000 kilobits, which is what the “get info” file
says is the suggested allocation. I know that the memory section of
the “get info” file was primarily for people still running os9, but every
time I play a game that involves a new map or some new file that hasn’t
been repeately used, I hear my hardrive running and my frames per second
drop. I just figured that if I could allocate all my memory to the game while i am playing it, it would run faster. I can’t use any other application anyway, so what the hell? Thanks for the help.

Can you type into the “Memory” section of the Get Info window? If so, that suggests that you’re actually running the app in the Classic environment, in which case you can allocate as much RAM as you want, since you’re essentially running it in Mac OS 9.

If you can’t actually type into the blank, then yeah, it’s a Carbon app (and a badly-written Carbon app at that) and there’s nothing you can do (short of trying to run it in Classic and see if it performs any better there). To try that out, click the “Open in the Classic environment” box in the top portion of the Get Info window.

Thanks, i did try to edit the blank memory and it’s locked.
Unfortunately I no longer have os9 on my computer. so im sol. : )
I can only think of the 3 possibilities,

  1. overwrite the get info file to see if that works.
  2. find some ram solution like previously mentioned.
  3. Invent something everyone on earth needs and be a billionare so
    I can purchase aspyre and write a trully genuine mac game from
    scratch. : )

As for your solutions:

  1. Well, if it’s a Carbon app (which it is, since you don’t have OS 9 on your Mac anymore), then the OS ignores those numbers completely - they only exist for running the app in Classic. If the machine is run via Carbon, then it gets OS X’s memory management. And that’s a Good Thing. You could change those numbers to 1000000000 each, and OS X would happily ignore them and assign the game as much memory as it requests/needs.
  2. What solution was previously mentioned? The only solution I can think of is for you to get more RAM, or for the makers of your app to release a patch that makes it a less crappily-written game.
  3. Yeah…let’s go with that one! :slight_smile:

i came across this. I want to try to purge all random memory right before
starting “Ghost Recon”

If it is possible to use applescript on carbon apps then I think there
may be a solution to my problem. I don’t want to compact any info
i just want to clean it all. It sounds drastic , but if you have ever met
a “gamer” you will understand.

Think of the children, won’t anybody think of the children