Shortcuts: Mobile | Active Topics | Newest Posts | Latest Freeware | Private Messaging | Contribute News | Archive 
  NEWS
  Search News
Browse by Category
News History
1SRC News RSS Feed
1SRC Podcast RSS Feed
Contribute News
  FORUMS
  Search Forums
Topic Specific
News
General
Applications
  Games
  Video
Deals & Promos
Developers
E-books
Mac / Linux
Medical
Podcast
Skins & Backgrounds
Wireless
Off-Topic
  Audio/Video
  Cellphones
  Digital Cameras
  Gaming
  Gadgets & Gizmos
  Non-Palm OS PDAs
  PCs/Laptops
  Tech Web
palm
pre
Foleo
T|X-Series
Z-Series
LifeDrive
Zire
Treo
Tungsten
Older Palms
Sony
VZ-Series
TH-Series
UX-Series
TJ-Series
NX-Series
TG-Series
NZ-Series
Older Clies
Tapwave
Zodiac
Garmin
iQue
Other Licensees
AlphaSmart
Fossil
Group Sense
Kyocera
LG
Samsung
Site Specific
Arcade
Comment/Suggest
  FREEWARE
  Search Freeware
Applications
Ebooks
Skins
Backgrounds
  ABOUT US
  Contact Us
Contribute News
About Us
Privacy Statement
  LOW PRICE SEARCH

Search for the lowest prices: 




  LINKS
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Go Back   1src Forums > Topic Specific > Developers
User Name
Password
FAQ Members List Calendar Chat Arcade Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
Old 02-20-2003, 04:26 AM   #1
zhamilton1
ScreensOS Designer
 
zhamilton1's Avatar
 
Join Date: Sep 2002
Location: Israel
Posts: 278 zhamilton1 is on a distinguished road
Post Feature Memory

I have done alot of testing on the Feature memory and for anyone who is having problems with dynamic memory space read on...

Feature memory is a feature that was added in OS 3.1
It allowed to allocate storage space and put the pointer in a specified feature slot. Each feature slot is identified by a feature ID which is 16bit (65,535 slots).

In PalmOS 3.5 you can allocate above 64KB. This is useful for allocating large amounts of data like off-screen windows on the new OS5 devices where the display is 320x320. This requires over 100KB which cannot be allocated on dynamic memory.

Reading speed is as fast as dynamic memory since it uses a direct pointer to the storage space. However you need to use DmWrite to write information to the space. This means that write speed is just as slow as writing to a record. However if the contents do not change much this is not a problem.

Feature memory lasts untill the device is reset. This means that if you need to store information that needs to be accessed quickly but in short bursts for example a launcher, then feature memory is the way to go since it does not take up dynamic memory and therefore you can use as much of the space that you want without interfering with other applications.

Each feature ID is asigned to a CreatorID. The CreatorID is a four letter char that describes the application such as 'tEXT'.

All this information is documented in the PalmOS Docs however I have discovered a way to allocate/destroy memory using pointers without having to store feature IDs.

Choose one feature ID that will be used for memory allocations. I generally use Feature ID 0. Then when you want to allocate new memory call FtrMemNew with the feature ID 0. Take the pointer and put it somewhere. Then call FtrUnregister and not FtrMemFree. Why? Because then it does not destroy the memory but frees the ID 0. That way next time you allocate just do the same thing and it will give you some more memory space.

To free a pointer call FtrSet and set the value of ID 0 to the pointer and then call FtrPtrFree. This will free the memory and unregister the ID 0 for a next allocation/destroy of data.

The only problem is that you must not loose a pointer or you will have memory being used for nothing.

If anyone you have any problems send me an email to zhamilton1@yahoo.co.uk or post here where I'll check up here and then.

I hope this has been useful info to you... (:
__________________
Zakai Hamilton
Screens Environment Designer+Coder
MSN+Email: zhamilton1@yahoo.co.uk
Blog: http://www.screensenvironment.blogspot.com
zhamilton1 is offline   Reply With Quote
Old 02-24-2003, 12:27 PM   #2
ayasin
Senior Member
 
ayasin's Avatar
 
Join Date: Sep 2002
Posts: 420 ayasin is on a distinguished road
Quote:
Originally posted by zhamilton1
The only problem is that you must not loose a pointer or you will have memory being used for nothing.


That is actually quite bad (more so than an ordinary mem leak) because you are leaking on the storage heap and that memory will not be reclaimed until a soft reset or your app is uninstalled.
__________________
Start by doing what's necessary, then what's possible and suddenly you are doing the impossible.
- St. Francis of Assisi
ayasin is offline   Reply With Quote
Old 02-24-2003, 12:51 PM   #3
Alistar
Technowizard
 
Alistar's Avatar
 
Join Date: Jan 2003
Location: Canada
Posts: 1,133 Alistar is on a distinguished road
I think I had that happen then. My NX said it had approx 4 megs of free memory left. I installed a skin and soft reset it so that it would install and that number jumped to approx 5 megs.
Alistar is offline   Reply With Quote
Old 02-24-2003, 07:12 PM   #4
iebnn
doumo arigatou robotosan
 
Join Date: Oct 2002
Location: UMass Amherst
Posts: 1,037 iebnn is on a distinguished road
Send a message via AIM to iebnn
Features are really easy to do.... but FtrPtrNew is confusing me
__________________
DragonEdit - powerful text, DOC, and HTML editor.
iebnn is offline   Reply With Quote
Old 02-24-2003, 11:20 PM   #5
ayasin
Senior Member
 
ayasin's Avatar
 
Join Date: Sep 2002
Posts: 420 ayasin is on a distinguished road
What about it confuses you?
__________________
Start by doing what's necessary, then what's possible and suddenly you are doing the impossible.
- St. Francis of Assisi
ayasin is offline   Reply With Quote
Old 02-25-2003, 05:55 AM   #6
iebnn
doumo arigatou robotosan
 
Join Date: Oct 2002
Location: UMass Amherst
Posts: 1,037 iebnn is on a distinguished road
Send a message via AIM to iebnn
Well, I've got an app that can't use global variables.. I've been having trouble putting a struct into feature memory with FtrPtrNew in one function then being able to get the values from that pointer in another function..
__________________
DragonEdit - powerful text, DOC, and HTML editor.
iebnn is offline   Reply With Quote
Old 02-25-2003, 09:03 PM   #7
ayasin
Senior Member
 
ayasin's Avatar
 
Join Date: Sep 2002
Posts: 420 ayasin is on a distinguished road
First of all zhamilton1 this us not a flame of your technique. I personally would not generally endorse using Feature Memory in the manner described in this section for the reason I stated earlier as well as the fact that DmWrite does some important things for you (one of the key things being bounds checking which is esp important on the storage heap). Additionally a pointer to feature memory is locked (preventing the palm from efficently compressing the storage heap) until you unallocate it so use it with care. I am, however, curious to see the code that you are having a problem with if you want to distill out the relavent portions into an example.
__________________
Start by doing what's necessary, then what's possible and suddenly you are doing the impossible.
- St. Francis of Assisi
ayasin is offline   Reply With Quote
Old 03-02-2003, 05:18 AM   #8
zhamilton1
ScreensOS Designer
 
zhamilton1's Avatar
 
Join Date: Sep 2002
Location: Israel
Posts: 278 zhamilton1 is on a distinguished road
Mem Leaks

Yes that is the main problem. However it does not destroy any of the storage data and since you normally only allocate small areas it does get to a point where you have defragmented data. However you gain the speed and low usage of dynamic data. It should not be used by applications which are rarely opened and closed quickly (like a word-proccessor). But for a launcher, it is great since you enter/exit a launcher like all the time, therefore speed is crucial. For debugging make it add an entry to some file (which will slow it down but give you debug data) and then provide a function which tries to unregister all feature data. If an entry still exists you know you have a memory leek. In the release version just dont include that part of the code. Then you wont have that problem. Note: With MemPtr you still have the same problem since if you forget the pointer the memory is unused in dynamic memory which much more smaller which can cause worse memory leaks than feature memory.
__________________
Zakai Hamilton
Screens Environment Designer+Coder
MSN+Email: zhamilton1@yahoo.co.uk
Blog: http://www.screensenvironment.blogspot.com
zhamilton1 is offline   Reply With Quote
Old 03-04-2003, 09:59 AM   #9
ayasin
Senior Member
 
ayasin's Avatar
 
Join Date: Sep 2002
Posts: 420 ayasin is on a distinguished road
Re: Mem Leaks

Quote:
Originally posted by zhamilton1
Yes that is the main problem. However it does not destroy any of the storage data and since you normally only allocate small areas it does get to a point where you have defragmented data.


You _could_ destroy data if say you are storing a string there, and you pass the string to a StrPrintF call that writes too much back. Also fragmentation is very bad on the storage heap because now you are affecting all other apps on the device negatively.

Quote:

Note: With MemPtr you still have the same problem since if you forget the pointer the memory is unused in dynamic memory which much more smaller which can cause worse memory leaks than feature memory.

That's not entirely true. While you will cause a mem leak, it will be cleaned up as soon as your application exits (because it's on your dynamic heap). This is not the case for lost feature memory; it requires a soft reset to reclaim this memory.

You may be correct that if you use this technique for a launcher you see some major benefit, but I think the risk associated with it should make most developers in most situations think twice.
ayasin is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cf Driver Campaign, Please Everyone!!!!! blueflame Clie NX-series 305 07-23-2004 05:10 PM
Sandisk memory stick Drivers, Resets, ... a FYI DeadFish Clie NX-series 6 01-29-2004 10:24 PM
How do you carry your extra memory sticks? rcxAsh General 37 01-23-2004 06:23 PM
Memory stick questions... shostetler General 2 01-22-2004 08:17 AM
Memory Stick Pro Earlier & Cheaper ... khyasad Clie NX-series 4 03-03-2003 08:35 AM


All times are GMT -5. The time now is 06:58 AM.

  AD HOSTS ?
  GOOGLE ADS ?
  AMAZON ADS ?

Powered by: vBulletin Version 3.0.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
©2001 Entity City, LLC. All rights reserved.