Results 1 to 11 of 11

Thread: Memory usage goes up rapidly mad

  1. #1
    Join Date
    Mar 2012
    Location
    Color :D
    Posts
    938
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Memory usage goes up rapidly mad

    Simba Code:
    Function PickItem: Boolean;
    var
      a: Integer;
      TPA  : TPointArray;
      ATPA : T2DPointArray;
      MP   : TPoint;
      tmpCTS : Integer;
    begin
      repeat
        FixDatSixHours;
        FindNormalRandoms;
        tmpCTS := GetColorToleranceSpeed;
        ColorToleranceSpeed(2);
        SetColorSpeed2Modifiers(0.58,0.87);

        FindColorsTolerance(TPA, 5533524, MSX1, MSY1, MSX2, MSY2, 8);
        SortTPAFrom(TPA, Point(MSCX, MSCY));
        ATPA := TPAtoATPAEx(TPA, 20, 15);
        //SortATPAFromSize(ATPA, 300, true);

        if Length(ATPA) < 1 then
        begin
          writeln('blabla');
        end else
        begin
          MP := MiddleTPA(ATPA[0]);
          MMouse(MP.x, MP.y, 1, 1);
          if WaitUptext('ake', 500) then
            ClickMouse2(mouse_Left);
        end;
        wait(RandomRange(300, 600));
      until InvFull;

      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    end;

    When my script reach this part, it will keep picking up items until inventory is full. But during this time, the memory usage keep going up, always end up having an error while my Simba memory usage is over 1.5gb.

    Is it because of the repeating of color finding function that cause this? Or is it because of other causes. And if so, how can I resolve this problem?

  2. #2
    Join Date
    Nov 2008
    Location
    Melbourne, Australia
    Posts
    2,240
    Mentioned
    3 Post(s)
    Quoted
    11 Post(s)

    Default

    I would suggest splitting it into 2 functions, one to find the TPA and the other to click it. That was how I made my scripts. Try that and see if it solves this problem
    Click here to find out how to get full screen without members! | Click here to check out my Ultimate Bitmap Tutorial! Edited to work with Simba! |

  3. #3
    Join Date
    Mar 2012
    Location
    Color :D
    Posts
    938
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by cycrosism View Post
    I would suggest splitting it into 2 functions, one to find the TPA and the other to click it. That was how I made my scripts. Try that and see if it solves this problem
    Can you explain how does that resolve the memory usage problem?

  4. #4
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Use wrappers, functions that return TPA and ATPA types will hog memory.

    TPAtoATPAExWrap(ATPA, TPA, 20, 15);

    We don't got a wrapper yet for middle tpa, you might want to push a fix for that.
    Last edited by masterBB; 08-24-2012 at 01:35 PM.
    Working on: Tithe Farmer

  5. #5
    Join Date
    Nov 2008
    Location
    Melbourne, Australia
    Posts
    2,240
    Mentioned
    3 Post(s)
    Quoted
    11 Post(s)

    Default

    Quote Originally Posted by CephaXz View Post
    Can you explain how does that resolve the memory usage problem?
    I had my functions setup like that and I never had any memory issues. Hence why I said "Try that and see if it solves this problem".
    Click here to find out how to get full screen without members! | Click here to check out my Ultimate Bitmap Tutorial! Edited to work with Simba! |

  6. #6
    Join Date
    Mar 2012
    Location
    Color :D
    Posts
    938
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by masterBB View Post
    Use wrappers, functions that return TPA and ATPA types will hog memory.
    You mind giving an example based on the function above? TPA and ATPA is the best object finding I've learnt

    EDIT: I see, so as long as the function has a 'wrap' in its name, it won't hog memory?


    Quote Originally Posted by cycrosism View Post
    I had my functions setup like that and I never had any memory issues. Hence why I said "Try that and see if it solves this problem".
    I'll try it and see how it goes. By splitting do you mean something like this?

    Simba Code:
    Function FindItem(x, y): Boolean;
    begin
      if found then
        Result := True;
    end;

    Procedure TakeItem;
    begin
      if FindItem(x,y) then
        mouse(x, y, left);
    end;
    Last edited by CephaXz; 08-24-2012 at 01:41 PM.

  7. #7
    Join Date
    Mar 2012
    Location
    Color :D
    Posts
    938
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    The wrapper function works amazingly! Thanks for all the help!

  8. #8
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    All the functions returning an array will hog the memory. This is because of a bug in pascalscript. We can't fix it, it is just another reason to wait for lape.
    Working on: Tithe Farmer

  9. #9
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    I agree with masterBB; wrappers will help substantially here. I had the same problem before with an early version of LividFarmer; something to do with constantly searching for a color, getting a TPA, and then slipping that into a 2DTPA. Let me modify your function a bit and we'll see if it's any better for you.

    Simba Code:
    Function PickItem: Boolean;
    var
      TPA  : TPointArray;
      ATPA : T2DPointArray;
      MP   : TPoint;
      tmpCTS : Integer;
    begin
      Result := False;  //Let's start off by making this function, by default, False

      tmpCTS := GetColorToleranceSpeed;     //Set all of these just one time...
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.58,0.87);

      repeat
        FixDatSixHours;
        FindNormalRandoms;

        FindColorsSpiralTolerance(MSCX, MSCY, TPA, 5533524, MSX1, MSY1, MSX2, MSY2, 8);  //Let's use spiral instead
        TPAtoATPAExWrap(TPA, 20, 15, ATPA);
        SortATPAFromFirstpoint(ATPA, Point(MSCX, MSCY));  //Sort this ATPA from our middle screen

        if (Length(ATPA) > 0) then     //Only proceed if...
        begin
          MP := MiddleTPA(ATPA[0]);
          MMouse(MP.x, MP.y, 1, 1);
          if WaitUptext('ake', 500) then
            ClickMouse2(mouse_Left);
        end;
        wait(RandomRange(300, 600));
      until(InvFull);

      Result := InvFull;

      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    end;

    Let me know if that helps any.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  10. #10
    Join Date
    Mar 2012
    Location
    Color :D
    Posts
    938
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by masterBB View Post
    All the functions returning an array will hog the memory. This is because of a bug in pascalscript. We can't fix it, it is just another reason to wait for lape.
    I see. That explains everything I need to know for now. Thanks!


    Quote Originally Posted by Flight View Post
    I agree with masterBB; wrappers will help substantially here. I had the same problem before with an early version of LividFarmer; something to do with constantly searching for a color, getting a TPA, and then slipping that into a 2DTPA. Let me modify your function a bit and we'll see if it's any better for you.

    Simba Code:
    Function PickItem: Boolean;
    var
      TPA  : TPointArray;
      ATPA : T2DPointArray;
      MP   : TPoint;
      tmpCTS : Integer;
    begin
      Result := False;  //Let's start off by making this function, by default, False

      tmpCTS := GetColorToleranceSpeed;     //Set all of these just one time...
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.58,0.87);

      repeat
        FixDatSixHours;
        FindNormalRandoms;

        FindColorsSpiralTolerance(MSCX, MSCY, TPA, 5533524, MSX1, MSY1, MSX2, MSY2, 8);  //Let's use spiral instead
        TPAtoATPAExWrap(TPA, 20, 15, ATPA);
        SortATPAFromFirstpoint(ATPA, Point(MSCX, MSCY));  //Sort this ATPA from our middle screen

        if (Length(ATPA) > 0) then     //Only proceed if...
        begin
          MP := MiddleTPA(ATPA[0]);
          MMouse(MP.x, MP.y, 1, 1);
          if WaitUptext('ake', 500) then
            ClickMouse2(mouse_Left);
        end;
        wait(RandomRange(300, 600));
      until(InvFull);

      Result := InvFull;

      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
    end;

    Let me know if that helps any.
    Thanks Flight, that helps a lot! Currently the function is very different from the one in first post this thread. I'm still doing some testings with it, so you can see I have not used Results in it. But I have taken some parts from the one you edit into my script!

    For the part where you only proceed if Length is more than 0, I always experience error out of range. The weird thing is it should just skip this step if Length is 0. So I made it to proceed when Length is less than 1 first, and do some failsafes. That solved my problem, but I don't know how lol.

  11. #11
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    Quote Originally Posted by masterBB View Post
    Use wrappers, functions that return TPA and ATPA types will hog memory.

    TPAtoATPAExWrap(ATPA, TPA, 20, 15);

    We don't got a wrapper yet for middle tpa, you might want to push a fix for that.
    https://github.com/MerlijnWajer/Simba/pull/127/files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •