× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



> From: Jon Paris
>
> Having said all that - given that the routine you call is a
> generic one used
> by many different functions, I'm not convinced that dynamic
> memory is really
> needed.  Why not just use fixed memory in the callee and map to that.  Or
> for that matter use IMPORT/EXPORT.

Whee!  Now you guys are getting into the FUN stuff!

I need to retrieve dynamic amounts of data, data whose size cannot be
determined at compile time.  Do I allocate the maximum amount of storage, or
dynamically allocate the storage as needed?  Well, that depends on a whole
bunch of things.

Let's look at static allocation in the callee.  First off, how many of these
modules are you going to have?  If you're talking about creating a nice 16MB
buffer for every file, and you have 100 files, you're talking about 1.6GB of
storage.  For every job.  That's a pretty serious amount of storage.

And what happens when you need to do this recursively?  Let's say you use
this procedure to handle a bill of materials.  You call the subprogram to
get the parent's components.  You start processing those records, and the
first thing you do is go get the components for the first child.  Well,
since everybody is sharing the same memory (in the callee), then this call
is going to wipe out the parent's component list.  Life becomes totally
rancid, dude.

On the other hand, how do you manage dynamic memory?  Do I have a big fat
buffer that I read everything into, and then allocate a buffer of the
correct size when I'm done?  Big waste of memory.  Or, I can allocate a
smaller chunk at a time (say 100 records), and then extend the chunk every
time I need to.  But this involves copying the old records every time I
extend the space.  Thirdly, I could allocate space a chunk at a time, and
then paste them all together at the end.  A nice compromise, but not
particularly intuitive at first glance.

On top of all this, the caller has to remember to release the data.  Whether
the caller does the release or calls the subprogram to do the release, this
is still under the control of the caller.

Whoo hoo!

We're having fun now!

Joe



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.