|
Temporarily claiming memory for an App |
|
Loris (11:05 4/7/2006) Phlamethrower (11:51 4/7/2006) monkeyson2 (12:46 4/7/2006) Loris (10:07 6/7/2006) David Buck (19:59 6/7/2006) Loris (08:49 7/7/2006) Loris (12:17 10/7/2006) Loris (13:50 12/7/2006) Phlamethrower (14:31 12/7/2006) David Buck (08:32 13/7/2006) Loris (12:52 13/7/2006) Loris (13:27 4/7/2006)
|
|
Tony Haines |
Message #77360, posted by Loris at 11:05, 4/7/2006 |
Ha ha, me mine, mwahahahaha
Posts: 1025
|
What is the EC standard way of claiming chunks of memory for a wimp app?
I'm programming in BASIC, and have been working on a front-end using AppBasic. I'm loading in a file, hanging on to it for a while, then processing it to produce another, which may be smaller or possibly quite a lot (several times) larger than the original. I could work out a maximum size, but it would basically involve processing the file twice, which might be slow. Ideally I'd like to just increase the wimpslot, but I'm unsure whether this will work in this system. (you can't release Basic DIMmed memory...)
I could temporarily claim a dynamic area, but I'm not sure it'll be easy or possible increase the size - it needs an upcall, or something, which I don't know about yet. |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #77361, posted by Phlamethrower at 11:51, 4/7/2006, in reply to message #77360 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
Use your own heap manager?
If you don't use BASIC for any dynamic allocation then you should (I think!) be able to read the value of HIMEM then create your own heap from HIMEM to the wimpslot limit for your app.
Alternatively, use C |
|
[ Log in to reply ] |
|
Phil Mellor |
Message #77362, posted by monkeyson2 at 12:46, 4/7/2006, in reply to message #77361 |
Please don't let them make me be a monkey butler
Posts: 12380
|
http://tofla.iconbar.com/tofla/gen/002/index.htm |
|
[ Log in to reply ] |
|
Tony Haines |
Message #77367, posted by Loris at 13:27, 4/7/2006, in reply to message #77361 |
Ha ha, me mine, mwahahahaha
Posts: 1025
|
Use your own heap manager? I don't have a heap that needs managing, I just want to be able to claim extra memory in a contiguous block as I use it. Paint et al. apparently use something called flexlib, which I don't have (and anyway, is in C).
If you don't use BASIC for any dynamic allocation then you should (I think!) be able to read the value of HIMEM then create your own heap from HIMEM to the wimpslot limit for your app. Doh! I'm using lots of local variables in a recursive procedures of relatively unknown depth.
Alternatively, use C Meh.
...(network goes all microsoft)...
Thanks Monkeyson. On second reading, if the heap can be embiggened after initialisation, it'll do what I need.
[Edited by Loris at 14:27, 4/7/2006] |
|
[ Log in to reply ] |
|
Tony Haines |
Message #77397, posted by Loris at 10:07, 6/7/2006, in reply to message #77362 |
Ha ha, me mine, mwahahahaha
Posts: 1025
|
http://tofla.iconbar.com/tofla/gen/002/index.htm I''m now using the WIMPheap library. The memory block seems to grow and shrink fine. There does seem to be an issue in that it crashes the app if there isn't enough free memory to expand the block. Which is a shame, because from my cursory examination (and IIRC the instructions) it looks like it is meant to return a failed flag. |
|
[ Log in to reply ] |
|
David Buck |
Message #77417, posted by David Buck at 19:59, 6/7/2006, in reply to message #77397 |
Member
Posts: 7
|
I can let you have some BASIC functions I developed for RiscCAD if you wish. These allow you to claim any number of blocks, and request a compaction or an addition to the memory. Email me if you want them. |
|
[ Log in to reply ] |
|
Tony Haines |
Message #77418, posted by Loris at 08:49, 7/7/2006, in reply to message #77417 |
Ha ha, me mine, mwahahahaha
Posts: 1025
|
I can let you have some BASIC functions I developed for RiscCAD if you wish. These allow you to claim any number of blocks, and request a compaction or an addition to the memory. Email me if you want them. Thanks David. I've sorted out the problem with WimpHeapLib now. I found it makes a call to wimpslot which it error-checks. Then it assumes that if that has gone through that it will be able to enlarge the block. That looks fine to me, but for some reason the first call can succeed and the second fail. Perhaps it is a change in the implementation of memory allocation before RISC OS 3.7.
So anyway, just checking for an error there seems to fix the problem (my program picks up the error and reports in an icon instead). |
|
[ Log in to reply ] |
|
Tony Haines |
Message #77495, posted by Loris at 12:17, 10/7/2006, in reply to message #77418 |
Ha ha, me mine, mwahahahaha
Posts: 1025
|
Waah, it still doesn't work. Now it stiffs the whole machine intermitently. |
|
[ Log in to reply ] |
|
Tony Haines |
Message #77582, posted by Loris at 13:50, 12/7/2006, in reply to message #77495 |
Ha ha, me mine, mwahahahaha
Posts: 1025
|
Well I think I've fixed it now. It seems a little odd for a routine to return some errors and let others (which are essentially the same error) be reported, but I've wrapped the thing in a local error routine, but generate my own for it to catch if it passes one back.
The program is starting to look dangerously close to being releasable. I'll need to decide what to do with it. |
|
[ Log in to reply ] |
|
Jeffrey Lee |
Message #77584, posted by Phlamethrower at 14:31, 12/7/2006, in reply to message #77582 |
Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot Hot stuff
Posts: 15100
|
For starters, you could tell us what it is |
|
[ Log in to reply ] |
|
David Buck |
Message #77598, posted by David Buck at 08:32, 13/7/2006, in reply to message #77584 |
Member
Posts: 7
|
Yeah, I hope it's not what I'm working on right now |
|
[ Log in to reply ] |
|
Tony Haines |
Message #77603, posted by Loris at 12:52, 13/7/2006, in reply to message #77598 |
Ha ha, me mine, mwahahahaha
Posts: 1025
|
Yeah, I hope it's not what I'm working on right now Probably not. It 'processes' Drawfiles. I call it Rollup. Perhaps you can guess what it does.
It may even be useful for some esoteric purposes. Actually I know it will be useful, at least for me because I've wanted it for some time. Any other RISC OS using plasmid biologists may also like it.
Oh, it occured to me today that I could probably do away with the heap management and just use the wimpslot calls. I may do this once it is fully functional. But the WIMPheap library would certainly be useful if I needed more than just 2 blocks. |
|
[ Log in to reply ] |
|
|