Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Rebol for real world applications

From: maximo:meteorstudios at: 19-Nov-2003 17:14

how much ram is your rebol taking... I've had it over 700MB without problems. how many different objects are you creating. there may be a limit amount of objects (contexts) per application, but given that I have applications which generate hundreds of view faces and corresponding data objects, I doubt this is a small number.
> -----Original Message----- > From: Sabu Francis [mailto:[sf--sabufrancis--com]] > Sent: Wednesday, November 19, 2003 4:39 AM > To: [rebol-list--rebol--com] > Subject: [REBOL] Rebol for real world applications
[... text snipped ...]
> the following func which converts the file into an object as > shown below: > > ;;;;Warning: UNTESTED CODE > > cfg: make object! [] ; global variable. Is this needed? > pp: [] ; global variable. Is this needed?
NOT needed! everything is global unless explicitely local.
> loadCfg: function [cfgfile] [kk] > [ > > either error? try [ kk: read cfgfile > pp: to-block kk > ] > > [ return false ] > [ > cfg: make object! pp > clear pp; > return true > ] > > ]
take the habbit to ALWAYS do: pp: COPY [] ; explained below in more detail. also clear pp will only clear from current point of pp, so if pp isn't at the head of the block, it won't really clear it. you should: clear HEAD pp but this depends if pp ever gets offset or not (in the above code It shouldn't).
> Once the configuration file becomes an object, then I pick up > the configuration parameter I want by using the appropriate > path into that object.
this should not be a problem.
> The second part of the reason for these crashes could be that > each email is opened up, footers are inserted into the email > and then given over to another function to be sent to the > mailing list subscribers. All that must be taking up memory. > The question here is: How does memory management work in > Rebol?
any unsused data (no words point to it, or the data is not in a block) will eventually be cleaned up. Another point is that contexts (objects and blocks on which you call 'BIND or 'CONTEXT) will only disapear if no words are pointing to them or any of their members. this is called garbage collection. I've had a problem where I had done this: my-setup: function [arg] [blk][ blk: [] append blk arg ] instead of: my-setup: function [arg] [blk][ blk: COPY [] append blk arg ] even if blk is a local variable, it is still the same block each time the function is called. What will happen if you iterate through the block and setup another piece of code with every value in it, is that you will accumulate all the previous setups and RE-apply them over and over. in the end, it works, but your application will get slower and slower. This also had the side effect that the blk will eventually be HUGE. When doing tests on scientific data, I had HUGE datasets of 40 000 rows by 100 columns and rebol never winced. BUT at some point I forgot ONE copy and, I accumulated the 1-40000 rows over and over, this would eventually bust a few GBs of ram... so this might be what is happening to you to...
>Are global variables better than local ones?
Not in terms of memory management. most local variables end up hanging around, unused in between each call of your function, anyways.
> I would > appreciate any help. The thing is driving me nuts :-) (As you > can see, there are too many smileys already in my post)
HTH! -MAx