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

[REBOL] Re: Rebol for real world applications

From: sf:sabufrancis at: 20-Nov-2003 10:45

Hi: Thank you Max and thank you Romano. I fixed the problem this way. I gave up the idea of using an object, because as Romano had pointed out; it can be insecure when the block is converted to an object, the code will get executed. I cannot afford to have my users put up some arbitrary Rebol code inside the configuration file -- say to mail out out the secret recipe for everlasting youth which is residing on my server :-) to them or do something more sinister. So now I'm using the following code ;;;Warning: Untested code loadCfg: function [cfgfile] [pp] [ either error? try [ pp: load/all cfgfile] [ return false ] [ forskip pp 2 [set first pp second pp] pp: none return true ] ] The cfgfile contains parameters that are written in name value pairs using Rebol syntax, thus: a: {Something in the way she moves attracts me like no other lover } c: "Something in the way" c: ["she" "woos" "me"] d: 9 e: [george--something--com] Using the forskip statement in my code, the appropriate global variables are setup. Though I dont like global variables generally (a habit picked up while programming in other languages) I guess I'll live with that for now. I am hoping that the way the globals are setup using the forskip statement, I would be preventing people from putting executable code into the configuration file Or have I got that wrong? Is there a better way of doing it? Max, your idea of using instead of using pp: copy [] I am using pp: none after the routine has finished using pp. This idea I got from a post from Carl who said that the reference to the first frame of a function (i.e. when the first time a local variable is used) hangs around if it is not reset by another call to the function. In fact, I've gone around setting the local variables in all my functions to none -- and that seems to have improved the situation fairly. Regards Sabu P.S: I like Beatles -- their songs are part of the secret recipe ;-) ----- Original Message ----- From: "Maxim Olivier-Adlhoch" <[maximo--meteorstudios--com]> To: <[rebol-list--rebol--com]> Sent: Thursday, November 20, 2003 3:44 AM Subject: [REBOL] Re: Rebol for real world applications
> 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...