# Preferences: Maximum Memory

**URL:** <https://discourse.processing.org/t/preferences-maximum-memory/40525>\
**Category:** Processing\
**Created:** [January 9, 2023, 3:57pm UTC](https://discourse.processing.org/t/preferences-maximum-memory/40525 "2023-01-09T15:57:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![fredstout](https://avatars.discourse-cdn.com/v4/letter/f/258eb7/32.png) [@fredstout](https://discourse.processing.org/u/fredstout)\
**Post date:** [January 9, 2023, 3:57pm UTC](https://discourse.processing.org/t/preferences-maximum-memory/40525/1 "2023-01-09T15:57:56Z")

</div>

My compiles began taking too long and my sketch seems to require too many mouse clicks to actually perform the mouse click function. I am thinking that this is a memory problem so I increased the maximum memory available to 800 MB. No change that I could see.  
What are the recommendations for setting maximum memory?

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [January 9, 2023, 4:33pm UTC](https://discourse.processing.org/t/preferences-maximum-memory/40525/2 "2023-01-09T16:33:05Z")

</div>

Hi @fredstout,

That’s too less information to give a qualified answer.

If the event handling ie. mouse clicks gets processed slow this is not necessarily a memory issue.  
Tell or show a bit more what you are currently doing in your code and let us know what you’re trying to achieve…

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![fredstout](https://avatars.discourse-cdn.com/v4/letter/f/258eb7/32.png) [@fredstout](https://discourse.processing.org/u/fredstout)\
**Post date:** [January 9, 2023, 6:57pm UTC](https://discourse.processing.org/t/preferences-maximum-memory/40525/3 "2023-01-09T18:57:41Z")

</div>

Thank you for your prompt response. In looking at your response, it occurred to me that I really asked two questions:

1. What is the guidance relative to the maximum memory option under preferences?

2. Why is my mouse so slow? My first reaction was to think that I had put too much code in the mouseClicked function. I think of the mouseClick function as an interrupt service routine and that it should be as small (read quick) as possible. I rewrote it as follows (sorry, I can’t find the code formatter control)

This sketch is a Bingo Sketch, Ball numbers are displayed on the screen and when selected (mouse) they are highlighted. There are other options:

//MOUSECLICKED////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  
void mouseClicked (){  
int x = 0,i;

float xd = BoxWidth/2 \* .95;  
float yd = BoxHeight/2 \* .95;  
boolean nb = false;

//… Clicking upper left corner of the screen is a prompt(quick) exit  
if (TRACE) println ("mouseClicked: Mouse: " + mouseX + “/” + mouseY);  
if (mouseX \< 20 && mouseY \< 20){  
ExitNow = true;  
return;  
}

//… Check for a ball selection  
BallSelected = false;

for (x = 1; x \< 76; x++){  
if (mouseX \> BoxX - xd && mouseX \< BoxX + xd && mouseY \> BoxY - yd && mouseY \< BoxY + yd){  
BallSelected = true;  
NewBall = x;  
if (TRACE) println (" new ball: " + x);  
ScreenChange = true;  
break;  
}  
}  
if (BallSelected) return;

// if a ball was not selected, check for command

//\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* G O B A C K 1 B A L L \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
if (PB\_Back.Selected()){  
if (LastBall == -1) {  
NewGame();  
ClearScreen();  
return;  
}  
PB\_Back.On(Green);  
Backone = true;  
return;  
}

//\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* N E W G A M E \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
if (PB\_New.Selected()){  
NewGame();  
ClearScreen();  
ScreenChange = false;  
return;  
}

//\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* E X I T \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
if (PB\_Exit.Selected()) Close();

//\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* N O M O N E Y B A L L O R W I L D C A R D I F G A M E R U N N I N G \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
if (GameRunning) return;

//\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* M O N E Y B A L L \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

if (PB\_Moneyball.Selected()){  
Moneyball = !Moneyball;  
if (TRACE) println ("MB Pushbutton: " + Moneyball + " ball: " + MoneyBall);  
if (Moneyball == false){  
PB\_Moneyball.label(“MB”);  
PB\_Moneyball.Off(Red);  
} else {  
PB\_Moneyball.label(nf(MoneyBall,0));  
PB\_Moneyball.On(Green);

}  
ScreenChange = true;  
return;  
}

//\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* W I L D C A R D \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
if (PB\_Wildcard.Selected()){  
Wildcard = !Wildcard;  
if (TRACE == true) println ("WC Pushbutton: " + Wildcard + " ball: " + Wildcard);  
if (Wildcard == false) {  
PB\_Wildcard.Off(Red);  
} else {  
WildCard = LeastSignificant (BaseNumber(“WC”), “WC”); // generates a new wild card number (0 - 9  
PB\_Wildcard.On(Green);  
}  
ScreenChange = true;  
return;  
}  
}//…End of Mouseclicked

```auto
// MOUSECLICKED
void mouseClicked() {
  int x = 0, i;

  float xd = BoxWidth/2 * .95;
  float yd = BoxHeight/2 * .95;
  boolean nb = false;

  //..... Clicking upper left corner of the screen is a prompt(quick) exit
  if (TRACE) println ("mouseClicked: Mouse: " + mouseX + "/" + mouseY);
  if (mouseX < 20 && mouseY < 20) {
    ExitNow = true;
    return;
  }

  //..... Check for a ball selection
  BallSelected = false;

  for (x = 1; x < 76; x++) {
    if (mouseX > BoxX[x] - xd && mouseX < BoxX[x] + xd && mouseY > BoxY[x] - yd && mouseY < BoxY[x] + yd) {
      BallSelected = true;
      NewBall = x;
      if (TRACE) println (" new ball: " + x);
      ScreenChange = true;
      break;
    }
  }
  if (BallSelected) return;

  // if a ball was not selected, check for command

  / *****************************************G O B A C K 1 B A L L************************************************** /
  if (PB_Back.Selected()) {
    if (LastBall == -1) {
      NewGame();
      ClearScreen();
      return;
    }
    PB_Back.On(Green);
    Backone = true;
    return;
  }

  / ***********************************************N E W G A M E******************************************************** /
  if (PB_New.Selected()) {
    NewGame();
    ClearScreen();
    ScreenChange = false;
    return;
  }

  / *****************************************************E X I T************************************************************ /
  if (PB_Exit.Selected()) Close();

  / ****************N O M O N E Y B A L L O R W I L D C A R D I F G A M E R U N N I N G****************** /
  if (GameRunning) return;

  / ************************************************M O N E Y B A L L****************************************************** /

  if (PB_Moneyball.Selected()) {
    Moneyball = !Moneyball;
    if (TRACE) println ("MB Pushbutton: " + Moneyball + " ball: " + MoneyBall);
    if (Moneyball == false) {
      PB_Moneyball.label("MB");
      PB_Moneyball.Off(Red);
    } else {
      PB_Moneyball.label(nf(MoneyBall, 0));
      PB_Moneyball.On(Green);
    }
    ScreenChange = true;
    return;
  }

  / ***********************************************W I L D C A R D******************************************************** /
  if (PB_Wildcard.Selected()) {
    Wildcard = !Wildcard;
    if (TRACE == true) println ("WC Pushbutton: " + Wildcard + " ball: " + Wildcard);
    if (Wildcard == false) {
      PB_Wildcard.Off(Red);
    } else {
      WildCard = LeastSignificant (BaseNumber("WC"), "WC"); // generates a new wild card number (0 - 9
      PB_Wildcard.On(Green);
    }
    ScreenChange = true;
    return;
  }
}
//....End of Mouseclicked

```

EDIT: Add formatted Code (mnse)

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [January 9, 2023, 8:06pm UTC](https://discourse.processing.org/t/preferences-maximum-memory/40525/4 "2023-01-09T20:06:54Z")

</div>

Hi @fredstout,

Will have a look tomorrow, but please follow the rule from below first…

Cheers  
— mnse

* * *

We kindly ask you to please format your code. This will make it easier for other community members to help you. If you need help you can check the [FAQ section on code formatting](https://discourse.processing.org/faq#format-your-code). Thanks!

![ezgif.com-gif-maker (1)](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/3/4/34521338de6902479873291389bf53a11d12237d.gif)

* * *

---

<div class="post-metadata">

**Author:** ![fredstout](https://avatars.discourse-cdn.com/v4/letter/f/258eb7/32.png) [@fredstout](https://discourse.processing.org/u/fredstout)\
**Post date:** [January 9, 2023, 10:22pm UTC](https://discourse.processing.org/t/preferences-maximum-memory/40525/5 "2023-01-09T22:22:36Z")

</div>

I realize the need to format code, I want to do that, and I read the instructions but there is no format control to enable me to do that.

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [January 10, 2023, 7:27am UTC](https://discourse.processing.org/t/preferences-maximum-memory/40525/6 "2023-01-10T07:27:03Z")

</div>

Hi @fredstout,

I’ve added a formatted version of your code below yours. Please remove the unformatted one.

> [@fredstout](#):
>
> - What is the guidance relative to the maximum memory option under preferences?

I would say … As long you’re not getting an error which says that the VM runs out of heap space, leave it as it is by default.

> [@fredstout](#):
>
> Why is my mouse so slow? My first reaction was to think that I had put too much code in the mouseClicked function. I think of the mouseClick function as an interrupt service routine and that it should be as small (read quick) as possible. I rewrote it as follows

Hard to say, without testing the whole program and see the effective result to find the bottleneck.  
From a first sight, the code in the mouse handling, even if it is as long as yours, shouldn’t be an issue, at lease if you are not acting on it like on an idle clicker game. I would use mousePressed or mouseReleased function instead mouseClicked, as mouseClicked gets triggered after a combined mousePressed/mouseReleased action, but this also shouldn’t be an issue.

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![sableraph](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sableraph/32/251_2.png) [@sableraph](https://discourse.processing.org/u/sableraph)\
**Post date:** [January 10, 2023, 11:04am UTC](https://discourse.processing.org/t/preferences-maximum-memory/40525/7 "2023-01-10T11:04:40Z")

</div>

In some cases the `</>` button may not appear immediately. In this case you will find the option under the gear icon (the last button to the right on the editor’s header bar). I updated the FAQ to clarify this.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/0/1/01e256f78b2643cc92f80c4789112e82f9d2c618.png)

---

<div class="post-metadata">

**Author:** ![fredstout](https://avatars.discourse-cdn.com/v4/letter/f/258eb7/32.png) [@fredstout](https://discourse.processing.org/u/fredstout)\
**Post date:** [January 10, 2023, 12:25pm UTC](https://discourse.processing.org/t/preferences-maximum-memory/40525/8 "2023-01-10T12:25:27Z")

</div>

Thank you for your assistance, it is greatly appreciated. I changed the code to use mousepressed and it did seem to operate better than before. Thank you.
