Re: new and delete in Palm
Thanks Dave and Ben for the answers and sorry for the rather late reply. Ben, I also read an article of yours Inside the Palm OS :... where you have described in details the StartUp routine in PalmOS in details. A good thing to know for all the aplm adevelopers. Thanks again. -Viren --- In [EMAIL PROTECTED], Ben Combee [EMAIL PROTECTED] wrote: The 64K limitation I think is an arbitrary choice. If I recall correctly, the chunk header allows up to 16M chunks, but they limit it to 64K because the hotsync protocol only supports up to 64K record sizes. Palm OS 1.0 and 2.0 had memory heaps that were limited to 64K, so it wasn't actually possible to allocate a block of memory larger than that size. This heap structure was reworked in Palm OS 3.0, but the HotSync protocol wasn't fixed to support these large chunks. Palm OS 3.5 provided a back door to allocating large chunks, and this is used by the MemGluePtrNew call in the glue library included in Palm OS SDK 5.0 R2. -- Ben Combee [EMAIL PROTECTED] CodeWarrior for Palm OS technical lead Palm OS programming help @ www.palmoswerks.com -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/ -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: new and delete in Palm
On Wed, Aug 13, 2003 at 07:42:06PM -, drvirens wrote: Dave, would you please take this opportunity and let us know furhter in this direction ? I have read somewhere that palm devices dont have any MMU. Let me keep it in this way please...My understadning is that Palm OS does not have any virtual memory...so its all segment/chunk oriented stuff. Does that the reason why any resource in Palm cannt be larger than 64K ? And thencannt I hide the physical addresses behind the handles ? I thought a handle is really a pointer to pointer. I particularly wanna know more on how does the system make up for lack of a typical MMU ? The Dragonball processor doesn't have a MMU, but the existence or lack of a MMU is not really related to how the PalmOS memory manager works. Grossly simplified, an MMU is used to map a memory address to some other address. This is useful in a multitasking OS so that each process thinks that its memory starts at address 0. The MMU takes care of mapping the process' virtual address to a real physical address. At a higher level, you still need something to manage the memory space so that when an app calls malloc, or MemHandleNew, or whatever (including indirect calls through the new operator), the app gets something, and when the app frees up the memory (via free, MemHandleFree, delete, etc.), the space is again marked as free. This is also a called a memory manager, but has nothing to do with the MMU. A memory chunk is just an arbitrary name that the PalmOS developers gave to a piece of memory that is managed by the PalmOS memory manager. Every OS call that allocates memory (MemPtrNew, MemHandleNew, MemHandleResize, DmNewRecord, DmResizeRecord, etc.) will eventually get a chunk that the memory manager has decided it can have. The 64K limitation I think is an arbitrary choice. If I recall correctly, the chunk header allows up to 16M chunks, but they limit it to 64K because the hotsync protocol only supports up to 64K record sizes. -- Dave Carrigan Seattle, WA, USA [EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680 UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL Dave is currently listening to Elvis Costello - No Dancing (My Aim Is True) -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
RE: new and delete in Palm
At 05:34 AM 8/13/2003, Mayank Babu Rastogi, Noida wrote: Hi Chris, Thanks. Palm OS 5 API reference document doesn't talk about new and delete. Is there any additional library which provides these functions ? They aren't mentioned in the API reference as these aren't OS functions, but the responsibility of your development environment. With CodeWarrior, you just link in the standard Palm OS runtime library, something done automatically with projects created by the CW for Palm OS wizards. -- Ben Combee [EMAIL PROTECTED] CodeWarrior for Palm OS technical lead Palm OS programming help @ www.palmoswerks.com -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: new and delete in Palm
On Wed, Aug 13, 2003 at 10:11:29PM -, drvirens wrote: Dave, The 64K limitation I think is an arbitrary choice. If I recall correctly, the chunk header allows up to 16M chunks, but they limit it to 64K because the hotsync protocol only supports up to 64K record sizes. Again, I have a doubt. Sorry for this Dave. But I am not gettin why would the hotsynch protocol needs to be restricted to handle a data of 64K _only_ ?I mean, why not 32K or 128K or whatever? Is it just an arbitrary decision again ? You would have to ask the PalmOS development team why they chose that number. -- Dave Carrigan Seattle, WA, USA [EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680 UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL Dave is currently listening to Neil Young - Helpless (Unplugged) -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: new and delete in Palm
On Wed, Aug 13, 2003 at 12:57:15PM -, drvirens wrote: AFAIK, the implementation of new keyowrd on Palm is such that it always calls the MemPtrNew() API of the Memory Manager internally...so you are really given a direct physical address by the system. Since this poiner is not locked, it may become a dangling pointer should the system run a compaction routine or other similar job behind your back. So, the wise thing to do would be to use the new only if you are sure you are not gonna need the object for longer periods of times. Guys, please correct me if I am wrong. You're wrong on this part. MemPtrNew allocates a non-movable chunk that is immune to compaction or defragmentation. MemHandleNew allocates a movable chunk that will be essentially flagged as non-movable when you lock it with MemHandleLock. It's perfectly safe to allocate long-lived pointers with new. The only thing is that it can cause memory fragmentation (this is generally true in any OS, but on small-memory systems it can be more of a problem). However, the same thing can be said if you allocate a handle and lock it for the length of the program. -- Dave Carrigan Seattle, WA, USA [EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680 UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: new and delete in Palm
The 64K limitation I think is an arbitrary choice. If I recall correctly, the chunk header allows up to 16M chunks, but they limit it to 64K because the hotsync protocol only supports up to 64K record sizes. Palm OS 1.0 and 2.0 had memory heaps that were limited to 64K, so it wasn't actually possible to allocate a block of memory larger than that size. This heap structure was reworked in Palm OS 3.0, but the HotSync protocol wasn't fixed to support these large chunks. Palm OS 3.5 provided a back door to allocating large chunks, and this is used by the MemGluePtrNew call in the glue library included in Palm OS SDK 5.0 R2. -- Ben Combee [EMAIL PROTECTED] CodeWarrior for Palm OS technical lead Palm OS programming help @ www.palmoswerks.com -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: new and delete in Palm
At 05:36 AM 8/13/2003, Chris Apers wrote: Don't think so, just enable C++ compiler in your project. I use them with no problem. Don't use the Enable C++ Compilation switch in CodeWarrior. CW will always build a .cpp or .c files as C++. This switch just forces it to also build .c files as C++, rather than using C rules for the file. In V9, the wording was changed to Force C++ Compilation. -- Ben Combee [EMAIL PROTECTED] CodeWarrior for Palm OS technical lead Palm OS programming help @ www.palmoswerks.com -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: new and delete in Palm
Nice! That's about like saying the display is limited to 160x160 because there are 52 wednesdays in 2003. Not that I'm bitter about trying to use large datasets you understand :) The 64K limitation I think is an arbitrary choice. If I recall correctly, the chunk header allows up to 16M chunks, but they limit it to 64K because the hotsync protocol only supports up to 64K record sizes. Regards, Paul Johnson Applewood House www.applewoodhouse.com - Original Message - From: Dave Carrigan [EMAIL PROTECTED] To: Palm Developer Forum [EMAIL PROTECTED] Sent: Wednesday, August 13, 2003 10:29 PM Subject: Re: new and delete in Palm On Wed, Aug 13, 2003 at 07:42:06PM -, drvirens wrote: Dave, would you please take this opportunity and let us know furhter in this direction ? I have read somewhere that palm devices dont have any MMU. Let me keep it in this way please...My understadning is that Palm OS does not have any virtual memory...so its all segment/chunk oriented stuff. Does that the reason why any resource in Palm cannt be larger than 64K ? And thencannt I hide the physical addresses behind the handles ? I thought a handle is really a pointer to pointer. I particularly wanna know more on how does the system make up for lack of a typical MMU ? The Dragonball processor doesn't have a MMU, but the existence or lack of a MMU is not really related to how the PalmOS memory manager works. Grossly simplified, an MMU is used to map a memory address to some other address. This is useful in a multitasking OS so that each process thinks that its memory starts at address 0. The MMU takes care of mapping the process' virtual address to a real physical address. At a higher level, you still need something to manage the memory space so that when an app calls malloc, or MemHandleNew, or whatever (including indirect calls through the new operator), the app gets something, and when the app frees up the memory (via free, MemHandleFree, delete, etc.), the space is again marked as free. This is also a called a memory manager, but has nothing to do with the MMU. A memory chunk is just an arbitrary name that the PalmOS developers gave to a piece of memory that is managed by the PalmOS memory manager. Every OS call that allocates memory (MemPtrNew, MemHandleNew, MemHandleResize, DmNewRecord, DmResizeRecord, etc.) will eventually get a chunk that the memory manager has decided it can have. The 64K limitation I think is an arbitrary choice. If I recall correctly, the chunk header allows up to 16M chunks, but they limit it to 64K because the hotsync protocol only supports up to 64K record sizes. -- Dave Carrigan Seattle, WA, USA [EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680 UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL Dave is currently listening to Elvis Costello - No Dancing (My Aim Is True) -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/ -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
RE: new and delete in Palm
new and delete are not Palm OS functions, so you won't find them in the Palm OS reference. Instead, you should consult the documentation for your development system. -- Keith -Original Message- From: Mayank Babu Rastogi, Noida [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 13, 2003 3:35 AM To: Palm Developer Forum Subject: RE: new and delete in Palm Thanks. Palm OS 5 API reference document doesn't talk about new and delete. Is there any additional library which provides these functions ? -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: new and delete in Palm
Dave, You're wrong on this part. MemPtrNew allocates a non-movable chunk that is immune to compaction or defragmentation. MemHandleNew allocates a movable chunk that will be essentially flagged as non-movable when you lock it with MemHandleLock. Yikes!! :-P Thanks Dave for that piece of info. Apologies for the misinformation guys. Dave, would you please take this opportunity and let us know furhter in this direction ? I have read somewhere that palm devices dont have any MMU. Let me keep it in this way please...My understadning is that Palm OS does not have any virtual memory...so its all segment/chunk oriented stuff. Does that the reason why any resource in Palm cannt be larger than 64K ? And thencannt I hide the physical addresses behind the handles ? I thought a handle is really a pointer to pointer. I particularly wanna know more on how does the system make up for lack of a typical MMU ? It's perfectly safe to allocate long-lived pointers with new. The only thing is that it can cause memory fragmentation (this is generally true in any OS, but on small-memory systems it can be more of a problem). However, the same thing can be said if you allocate a handle and lock it for the length of the program. Neat. So till date I was under wrong impression. Bleeh!! Thanks again Dave for that beautiful piece of info. -Viren -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: new and delete in Palm
On Wed, Aug 13, 2003 at 04:04:56PM +0530, Mayank Babu Rastogi, Noida wrote: Thanks. Palm OS 5 API reference document doesn't talk about new and delete. Is there any additional library which provides these functions ? new and delete are C++ keywords. Why would they be documented in the PalmOS API? If the compiler you're using is C++, then you can use new and delete. -- Dave Carrigan Seattle, WA, USA [EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680 UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: new and delete in Palm
At 05:19 AM 8/13/2003, Mayank Babu Rastogi, Noida wrote: Hi, I'm supposed to port a C++ application from Windows to Palm. This application heavily uses standard C++ library functions - new and delete for memory allocation/deallocation . As per my understanding, new and delete are not supported in Palm. What could be the best alternative to these library functions? new and delete are supported. Both CodeWarrior and prc-tools (GCC) map implement new in terms of MemPtrNew, and delete using MemPtrFree. -- Ben Combee [EMAIL PROTECTED] CodeWarrior for Palm OS technical lead Palm OS programming help @ www.palmoswerks.com -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: new and delete in Palm
Dave, The 64K limitation I think is an arbitrary choice. If I recall correctly, the chunk header allows up to 16M chunks, but they limit it to 64K because the hotsync protocol only supports up to 64K record sizes. Again, I have a doubt. Sorry for this Dave. But I am not gettin why would the hotsynch protocol needs to be restricted to handle a data of 64K _only_ ?I mean, why not 32K or 128K or whatever? Is it just an arbitrary decision again ? I remember I was asked this question in an interview recently but shame on me, I have not done anything specific to find out the answers. :-) -Viren -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: new and delete in Palm
new and delete work fine on PalmOS but it use the dynamic heap which can be very limited on some devices (mainly TT and TT2) so you can really use large objects. Also take care to not use big tables on your code if you try to allocate a UInt16 table[64000] it while crash your app. Hi, I'm supposed to port a C++ application from Windows to Palm. This application heavily uses standard C++ library functions - new and delete for memory allocation/deallocation . As per my understanding, new and delete are not supported in Palm. What could be the best alternative to these library functions? Thanks and regards, Mayank -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: new and delete in Palm
Hey Mayank, I'm supposed to port a C++ application from Windows to Palm. Ah well! One more windows app gets on palm. cool. :-) This application heavily uses standard C++ library functions Hmmm. So please be advised that other than new and delete, you would have to take care of the functions that your windows application uses and you wont find them in palm. For e.g. palm environment does not have the standard C library ( or at least not exposed to application developers ) so one should really be making use of the calls of the undelrying OS i.e. Palm for various functionalities. Thus, you would have to replace all the occurences of strcpy() with StrCopy() of String Manager ( or perhaps with some API from Text Manager if you plan to internationalise your app in the future )! - new and delete for memory allocation/deallocation . As per the C++ Standards, the new keyword is supposed to do _two_ things : 1. Allocate the memory for an object from the heap 2. Having allocated the memory, run the objects constructor on that allocated memory. If you plan to use MemPtrNew() and MemPtrFree() as the parallel calls for new and delete in your app, please rememebr that MemPtrNew() would allocate the memory for you, but it will _not_ call the constructor on that memory. AFAIK, the implementation of new keyowrd on Palm is such that it always calls the MemPtrNew() API of the Memory Manager internally...so you are really given a direct physical address by the system. Since this poiner is not locked, it may become a dangling pointer should the system run a compaction routine or other similar job behind your back. So, the wise thing to do would be to use the new only if you are sure you are not gonna need the object for longer periods of times. Guys, please correct me if I am wrong. Thanks. -Viren --- In [EMAIL PROTECTED], Mayank Babu Rastogi, Noida [EMAIL PROTECTED] wrote: Hi, I'm supposed to port a C++ application from Windows to Palm. This application heavily uses standard C++ library functions - new and delete for memory allocation/deallocation . As per my understanding, new and delete are not supported in Palm. What could be the best alternative to these library functions? Thanks and regards, Mayank -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/ -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
RE: new and delete in Palm
Hi Chris, Thanks. Palm OS 5 API reference document doesn't talk about new and delete. Is there any additional library which provides these functions ? regards, Mayank -Original Message- From: Chris Apers [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 13, 2003 3:57 PM To: Palm Developer Forum Subject: Re: new and delete in Palm new and delete work fine on PalmOS but it use the dynamic heap which can be very limited on some devices (mainly TT and TT2) so you can really use large objects. Also take care to not use big tables on your code if you try to allocate a UInt16 table[64000] it while crash your app. Hi, I'm supposed to port a C++ application from Windows to Palm. This application heavily uses standard C++ library functions - new and delete for memory allocation/deallocation . As per my understanding, new and delete are not supported in Palm. What could be the best alternative to these library functions? Thanks and regards, Mayank -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/ -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
64K limit in Palm ( was Re: new and delete in Palm )
Thanks Ben! Didn't see that post and posted the question which you already had answered. Thanks Dave too for your reply. -Viren -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: new and delete in Palm
Don't think so, just enable C++ compiler in your project. I use them with no problem. Hi Chris, Thanks. Palm OS 5 API reference document doesn't talk about new and delete. Is there any additional library which provides these functions ? regards, Mayank -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: new and delete in Palm
Hi Mayank, MemPtrNew and MemPtrFree can be used for new/delete. Deepak - Original Message - From: Mayank Babu Rastogi, Noida [EMAIL PROTECTED] To: Palm Developer Forum [EMAIL PROTECTED] Sent: Wednesday, August 13, 2003 3:49 PM Subject: new and delete in Palm Hi, I'm supposed to port a C++ application from Windows to Palm. This application heavily uses standard C++ library functions - new and delete for memory allocation/deallocation . As per my understanding, new and delete are not supported in Palm. What could be the best alternative to these library functions? Thanks and regards, Mayank -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/ -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/