FWIW, we have a little internal program that uses a _lot_ of binary
resources and string tables - WAY in excess of the dynamic heap.

It is possible to allocate big blocks of memory outside of the normal
application heap using DmNewHandle.  There are two problems with this,
first, the memory is write protected.  Second, according to the docs, if you
crash and do not either free the handle or associate it with a database the
memory will be orphaned until the next soft reset.

You could get around write protection by mucking with registers or using a
couple of system use only calls, but that is *really* dangerous.  Remember,
if you have a bug and run amok in the heap, you crash your app, but if you
run amok with write protection off in data memory the user loses data -
perhaps all of it.

If moving const data to binary resources does not free up enough heap and if
performance is not critical one thing you might consider is C++ operator
overloading.  A programmer here ported a nifty, but memory intensive,
algorithm by wrapping the code in some clever classes.  Most of the source
code remained identical, but behind the scenes the classes converted
assignments, etc. into dmWrites and whatnot for regular database records.

It was actually pretty clever, and using dmWrite kept it safe.  You could
push the scheme even farther and cache individual elements in heap space,
but he didn't take it that far.

Good Luck,
-jjf

-----Original Message-----
From: Adam Wozniak [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 06, 2000 8:37 PM
To: Palm Developer Forum
Subject: Re: Need more memory


Tom Zerucha wrote:

> On Thu, Jul 06, 2000 at 04:20:53PM -0700, Adam Wozniak wrote:
> > I'm porting a piece of software to the Palm.  It's large and complex
enough that
> > I don't want to muck with it if I don't have to.
> >
> > I need more memory for data than what's in the dynamic heap.  Like 256 K
more.
> >
> > Do I have any easy options?
>
> OS 3.5 has a much larger dynamic heap.
>

When I compile the project in CodeWarrior, I get a total of 86K "code" and
280K "data".
(As well as all the expected link errors which follow).

> > I've begun thinking about tweaking hardware registers to give myself
read/write
> > access to upper memory, but I don't exactly know how to tell what areas
PalmOS thinks
> > are in use and what areas may be empty.
>
> There are memory unprotect calls that do what DmWrite does to access
> the memory.
>
> > (Yes, I know it's probably a bad idea, but I want to know exactly WHY it
is a bad idea,
> > and how to make it as safe as I can).
>
> Is there a reason you need to do lots of small scattered writes so you
> can't just allocate a bunch of records in a regular database and use
> DmWrite (that is what I do in the similar circumstance).

Actually, that was a great question.  It looks like a lot of this is
actually just large lookup tables.  I suppose I can make them
binary resources of some kind, and then munge a pointer to point at them.
Would that ensure they don't take up memory in the
dynamic heap?  Can I rely on these records being locked down for me, or
would I have to lock them myself?

--
Adam Wozniak                     Senior Software Design Engineer
                                 Surveyor Corporation
[EMAIL PROTECTED]                4548 Broad Street
[EMAIL PROTECTED]          San Luis Obispo, CA 93401



-- 
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/tech/support/forums/

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to