Why is my gallery app (designed using Glide) taking nearly 500mb RAM

I made a gallery app which show offline stored images using GLIDE library in recyclerView but when i view the Profiler in android Studio it shows me that the app is taking nearly 500mb memory. Is this normal that my app is taking this much memory.

However my app is not crashing but it hang sometimes while showing images and also images are load all togethor (i can see the size of scrollbar getting smaller)

Also after asking User-permission images are not shown instantly. I have to start the app again to view these images. Those images should have been visible after accepting the permission.

This is the normal look of my app  Sometime when scrolling some white space also come between the images.

1This is the normal look of my app.

2Sometime when scrolling some white space also come between the images (shown in brown shaped oval).

for reducing the memory, I tried to decrease the height of the imageView (thinking that may be now glide had to load less pixels) but didn’t work at all. for user-permission i tried using Android Developers Guide but still no luck.

// this is my main activity     private static final int MY_PERMISSIONS_REQUEST = 100;     private Cursor mCursor=null;      @Override     protected void onCreate(Bundle savedInstanceState) {         // layout initialization code         mCursor = getImageCursor();         requestStoragePermission();          recyclerView = findViewById(R.id.imageRecyclerView);         mAdapter = new mayankImageAdapter(this,mCursor);        //..... (setting the recyclerView)         RecyclerView.LayoutManager mLayoutManager = new StaggeredGridLayoutManager(2,StaggeredGridLayoutManager.VERTICAL);         recyclerView.setLayoutManager(mLayoutManager);         recyclerView.setItemAnimator(new DefaultItemAnimator());         recyclerView.setAdapter(mAdapter);      }      private void requestStoragePermission() {         if (ContextCompat.checkSelfPermission(MainActivity.this,                 Manifest.permission.READ_EXTERNAL_STORAGE)                 != PackageManager.PERMISSION_GRANTED) {             ActivityCompat.requestPermissions(MainActivity.this,                     new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},                     MY_PERMISSIONS_REQUEST);         }     }      @Override     public void onRequestPermissionsResult(int requestCode,                                            String permissions[], int[] grantResults) {         switch (requestCode) {             case MY_PERMISSIONS_REQUEST: {                 // If request is cancelled, the result arrays are empty.                 if (grantResults.length > 0                         && grantResults[0] == PackageManager.PERMISSION_GRANTED) {                      // permission was granted, yay! Do the                     // file-related task you need to do.                  }                 else {                      // permission denied, boo! Disable the                     // functionality that depends on this permission.                 }                 return;             }         }     }       public Cursor getImageCursor(){         try{             Uri externalUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;             String[] projection = new String[]{MediaStore.Images.Media._ID, MediaStore.Images.Media.TITLE,                             MediaStore.Images.Media.SIZE, MediaStore.Images.Media.DATA};             String sortOrder = MediaStore.Images.Media.TITLE+" ASC";              Cursor imageCursor = getContentResolver().query(externalUri,                         projection,null,null,sortOrder);             return imageCursor;         }catch(Exception e){             return null;         }     }     @Override     protected void onDestroy() {         mCursor.close();         super.onDestroy();     } } 

mayankImageAdapter.java

\ onBindViewHolder method     @Override     public void onBindViewHolder(@NonNull MyViewHolder myViewHolder, int position) {         if(imageCursor!=null) {             imageCursor.moveToFirst();             imageCursor.moveToPosition(position);             int strIndex = imageCursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);              String str = imageCursor.getString(strIndex);             File myimageloc = new File(str);             GlideApp.with(callingActivity).load(myimageloc).into(myViewHolder.imgView);          }else{             return;         }     } 

acitivity_main.xml

<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.RecyclerView android:layout_width="match_parent"     android:layout_height="match_parent"     android:scrollbars="vertical"     android:id="@+id/imageRecyclerView"     xmlns:android="http://schemas.android.com/apk/res/android" /> 

I want to know the reason why my app is taking so much memory and what are steps to decrease this memory and how can i show images just after asking permissions from the user.

Thanks

Taking a long time to load [on hold]

I have a php file that’s taking an extremely long time to load and when it is loaded it just return a blank page (still shows all CSS and stuff, but no outcome from the queries it was executing).

I am using Wamp server for this, the problematic part of the script is price_stocks case/function.

TIA

    <?php        /*------------includes--------------*/    include ('./includes/connections.php');    include ('./includes/brain_file.php');    include ('./includes/style_top.php');    /*------------includes--------------*/    echo "<center><main>Stockmarket</main><hr width='500px'>";    $  q_ry = array();    $  q_ry = "SELECT `stock_guide`             FROM `members_extra`             WHERE `playerid` = '".mysql_real_escape_string($  _SESSION['playerid'])."'             AND `stock_guide` = 'yes'";    $  guide = array();    $  guide = mysql_query($  q_ry);    if(!mysql_num_rows($  guide))    {      echo "Sorry, You must purchase a stock guide from the bar exchange to access the stock market!            <hr width='500px'>&gt;<a href='city.php'>Okay</a><hr width='500px'>";              include ('./includes/style_bottom.php');              exit();    }         if($  _GET['action'])         {           if(!in_array($  _GET['action'], array('view','buyqty','buyprice','portfolio','sell','remove')))            {              echo "Error, Invalid action!                    <hr width='500px'>&gt;<a href='city.php'>Back</a><hr width='500px'>";              include ('./includes/style_bottom.php');              exit();           }         }         $  _GET['action'] = isset($  _GET['action']) && ctype_alpha($  _GET['action']) ? trim($  _GET['action']) : 'index';         switch($  _GET['action'])         {           case 'view':           stock_view();           break;            case 'remove':           remove_stocks();           break;            case 'sell':           sell_stocks();           break;            case 'portfolio':           port_stocks();           break;            case 'buyprice':           price_stocks();           break;            case 'buyqty':           qty_stocks();           break;            default:           stock_home();           break;         }           function stock_home()         {           global $  pl;           echo "&gt; <a href='city.php'>Back</a><hr width='500px'>                  ".round_table('500')."                  <table width = '100%'>                  <tr>                  <td bgcolor = '#DfDfDf' align = 'center'>                  <br>                  &gt; <a href='stockmarket.php?action=portfolio'>Your Portfolio</a>                  <br><br></td></tr></table>                  ".end_round().round_table('500')."                  <table width = '100%'>                  <tr bgcolor = '#999999' style = 'text-align:center; font-weight:800;'>                  <td width='1%'><b>Stock Logo</b></td>                  <td width='33%'>Stock Price</td>                  <td width='1%'>Last 24h</td>                  </tr>";                   $  q_ry = array();                   $  q_ry = "SELECT *                           FROM `stock_market`                           ORDER BY `s_price` DESC";                  $  stocks = array();                  $  stocks = mysql_query($  q_ry);                  $  s = array();                  $  i = 0;                  while($  s = mysql_fetch_array($  stocks))                  {                  $  i++;                  if ($  i % 2) { $  color="#e3e3e3"; } else { $  color="#D8D8D8"; }                  echo "<tr bgcolor = $  color>                        <td width='1%'>                        <a href='stockmarket.php?action=view&XID=".$  s['s_id']."'>                        <img src='images/stocks/s".$  s['s_id'].".png' border='0' width = '125px'></a>                        </td>                        <td align = 'center'>                           <table width = '90%'>                              <tr><td width = '45%' align = 'left'><b>Stock price</b> </td><td width = '10%' align = 'center'>-</td><td width = '45%' align = 'right'> <b>$  ".number_format($  s['s_price'], 2)."</b></td></tr>";                        $  q_ry = array();                        $  q_ry = "SELECT *                                 FROM `stock_history`                                 WHERE `h_stock` = '".mysql_real_escape_string($  s['s_id'])."'                                 ORDER BY `h_id` DESC LIMIT 1";                        $  changes = array();                        $  changes = mysql_fetch_array(mysql_query($  q_ry));                        if($  changes['h_upordown'] == 'up')                        {                        echo "<tr><td width = '45%' align = 'left'><b>Price Change</b> </td><td width = '10%' align = 'center'>-</td><td width = '45%' align = 'right'> <font color=green><b>".number_format($  changes['h_change'], 3)."</b></font>                        <img src=images/stocks/sup.png border=0 alt='Up'>                        </td></tr>                        <tr><td width = '45%' align = 'left'><b>% Change</b> </td><td width = '10%' align = 'center'>-</td><td width = '45%' align = 'right'> <font color=green><b>".number_format((($  changes['h_change']/$  s['s_price'])*100),3)."%</b></font>                        <img src=images/stocks/sup.png border=0 alt='Up'></td></tr></table>                        </td>";                        }                        else if($  changes['h_upordown'] == 'down')                        {                        echo "<tr><td width = '45%' align = 'left'><b>Price Change</b> </td><td width = '10%' align = 'center'>-</td><td width = '45%' align = 'right'> <font color=red><b>".number_format($  changes['h_change'], 3)."</b></font>                        <img src=images/stocks/sdown.png border=0 alt='Down'>                        </td></tr>                        <tr><td width = '45%' align = 'left'><b>% Change</b> </td><td width = '10%' align = 'center'>-</td><td width = '45%' align = 'right'> <font color=red><b>".number_format((($  changes['h_change']/$  s['s_price'])*100),3)."%</b></font>                        <img src=images/stocks/sdown.png border=0 alt='Down'></td></tr></table>                        </td>";                        }                        else                        {                        echo "<tr><td width = '45%' align = 'left'><b>Price Change</b> </td><td width = '10%' align = 'center'>-</td><td width = '45%' align = 'right'> <b>".number_format($  changes['h_change'], 3)."</b></font>                        <img src=images/stocks/sstatic.png border=0 alt='No change'>                        </td></tr>                        <tr><td width = '45%' align = 'left'><b>% Change</b> </td><td width = '10%' align = 'center'>-</td><td width = '45%' align = 'right'> <b>".number_format((($  changes['h_change']/$  s['s_price'])*100),3)."%</b>                        <img src=images/stocks/sstatic.png border=0 alt='No change'></td></tr></table>                        </td>";                        }                        echo "<td bgcolor=#DFDFDF>                        <a href='stockmarket.php?action=view&XID=".$  s['s_id']."'>                        <img src='thumb.php?s=".$  s['s_id']."' border='0'></a></td>                        </tr>                        <tr bgcolor=$  color><td colspan=8> </td></tr>";                        }                        echo "</table>".end_round()."<br><hr width='500px'>&gt; <a href=city.php>Back</a><hr width='500px'></center>";          }         function stock_view()         {         global $  pl;         $  _GET['XID'] = abs(intval($  _GET['XID']));         if(!$  _GET['XID'])         {                       echo "Error, Invalid ID!                             <hr width = '500px'>&gt;<a href='stockmarket.php'>Back</a><hr width = '500px'>";         }         else         {                  $  q_ry = array();                   $  q_ry = "SELECT *                           FROM `stock_market`                           WHERE `s_id` = '".mysql_real_escape_string($  _GET['XID'])."'";                  $  stocks = array();                  $  stocks = mysql_query($  q_ry);                  if(!mysql_num_rows($  stocks))                  {                       echo "Error, Invalid ID!                             <hr width = '500px'>&gt;<a href='stockmarket.php'>Back</a><hr width = '500px'>";                  }                  else                  {                  $  s = array();                  $  s = mysql_fetch_array($  stocks);                  echo "&gt; <a href='stockmarket.php?action=portfolio'>Back</a><hr width='500px'><br>                        ".round_table('500')."                        <table width='100%' cellspacing='0' bgcolor = '#E3E3E3'>                        <tr><td align = 'center'>                        <img src='".$  s['s_image']."' border='0' width = '450px'>                        <table width='100%'>                        <tr bgcolor = '#FFFFFF'><td align = 'left'><center>                        <font color=#000000><b>",htmlentities($  s['s_name'])," (",htmlentities($  s['s_acronym']),")</b></font>                        </center>                        <br>",$  s['s_desc'],"</td></tr></table><br>                        </td></tr><tr><td>                        <br>                        <table width='100%'><tr><td width='50%' valign='top'>                        <table width='100%'>                        <tr><td width='40%'>                        <b>Acronym:</b></td><td>",htmlentities($  s['s_acronym']),"</td></tr>                        <tr><td colspan=2><hr width='100%'></td></tr>                        <tr><td><b>Director:</b></td><td>";                           echo htmlentities($  s['s_direct']);                         echo "</td></tr>                        <tr><td colspan='2'><hr width='100%'></td></tr>                        <tr><td><b>Forecast:</b></td><td>";                           $  q_ry = array();                          $  q_ry = "SELECT `h_upordown`                                   FROM `stock_history`                                   WHERE `h_stock` = '".mysql_real_escape_string($  _GET['XID'])."'                                   ORDER BY `h_id` DESC LIMIT 96";                          $  hist = array();                          $  hist = mysql_query($  q_ry);                          $  h = array();                          $  total = 0;                          while($  h = mysql_fetch_array($  hist))                          {                             if($  h['h_upordown'] == 'up')                             {                               $  total++;                             }                             if($  h['h_upordown'] == 'none')                             {                               $  total++;                             }                             if($  h['h_upordown'] == 'down')                             {                               $  total--;                             }                          }                          if($  total >= '72')                          {                            echo "Excelent";                          }                          else if($  total >= '48')                          {                            echo "Good";                          }                          else if($  total >= '24')                          {                            echo "Average";                          }                          else if($  total > '0')                          {                            echo "Bad";                          }                          else                          {                            echo "Poor";                          }                        echo "</td></tr>                        <tr><td colspan='2'><hr width='100%'></td></tr>                        <tr><td><b>Demand:</b></td><td>";                           if(!$  s['s_available'])                          {                            echo "High";                          }                          else if(!$  s['s_sold'])                          {                            echo "Low";                          }                          else                          {                            echo "Average";                          }                        echo "</td></tr>                        </table>                         </td><td width='50%' valign='top'>                        <table width='100%'>                        <tr><td width='40%'><b>Current price:</b></td><td>$  ".number_format($  s['s_price'],4)."</td></tr>                        <tr><td colspan='2'><hr width='100%'></td></tr>                        <tr><td><b>Market cap:</b></td><td>";                           echo money_alter($  s['s_price']*($  s['s_sold']+$  s['s_available']));                        echo "</td></tr>                             <tr><td colspan='2'><hr width='100%'></td></tr>                             <tr><td><b>Total shares:</b></td><td>";                           echo number_format($  s['s_sold']+$  s['s_available']);                               echo "</td></tr><tr><td colspan=2><hr width=100%></td></tr>                                   <tr><td><b>Shares for sale:</b></td><td>";                           echo number_format($  s['s_available']);                              echo "</td></tr>                                    </table>                                   <br>                                   </td></tr></table>                                   </td></tr>                                   <tr><td><center><br>                                   &gt;<a onClick=\"showHistory(24)\">View/Hide last 24 hours</a>                                   <div id = '24graph' style = 'display:none;'>                                   <font color= '#000000'><b>Stock performance chart (24 hours)</b></font><br/>                                   <img src='24graph.php?s=".$  s['s_id']."'>                                   <br>                                   </div>                                    </td></tr>                                   <tr><td align = 'center'>                                   <div id = '24ticks' style = 'display:none;'><br>                                   <font color=#000000><b>Latest price changes in the past 24 hours</b></font><br>                                   <table width='100%'><tr><td width = '33%' valign = 'top'>                                    <table width='100%'>";              $  q_ry = array();              $  q_ry = "SELECT *                        FROM `stock_history`                        WHERE `h_stock` = '".mysql_real_escape_string($  s['s_id'])."'                        ORDER BY `h_id` DESC LIMIT 32";              $  stoc = array();              $  stoc = mysql_query($  q_ry);              $  st = array();              while($  st = mysql_fetch_array($  stoc))             {              echo "<tr><td align=left width=25%><b>".date('h',$  st['h_time']).":".date('i',$  st['h_time'])."</b></td>                    <td align=center width=25%>$  ".number_format($  st['h_price'],2)."</td>                    <td align=right width=33%>";                    if($  st['h_upordown'] == 'up' && $  st['h_change'] != '0.0000')                    {                                       if($  st['h_change'] > '0.0009')                    {                    echo "<font color=green>".number_format($  st['h_change'],3)."</font>                    <img src=images/stocks/sup.png border=0></td></tr>";                    }                    else                       {                    echo "<font color=green>".number_format($  st['h_change'] , 4, '.', '')."</font>                    <img src=images/stocks/sup.png border=0></td></tr>";                       }                    }                    else if($  st['h_upordown'] == 'down' && $  st['h_change'] != '0.0000')                    {                    if($  st['h_change'] > '0.0009')                    {                    echo "<font color=red>".number_format($  st['h_change'],3)."</font>                    <img src=images/stocks/sdown.png border=0></td></tr>";                    }                    else                       {                    echo "<font color=red>".number_format($  st['h_change'] , 4, '.', '')."</font>                    <img src=images/stocks/sdown.png border=0></td></tr>";                       }                    }                    else                    {                    echo "".number_format($  st['h_change'],2)." <img src=images/stocks/sstatic.png border=0></td></tr>";                    }             } echo "</table>    </td><td width = '33%' valign = 'top'>    <table width=100%>";              $  q_ry = array();              $  q_ry = "SELECT *                        FROM `stock_history`                        WHERE `h_stock` = '".mysql_real_escape_string($  s['s_id'])."'                        ORDER BY `h_id` DESC LIMIT 32,32";              $  stoc = array();              $  stoc = mysql_query($  q_ry);              $  st = array();              while($  st = mysql_fetch_array($  stoc))             {              echo "<tr><td align=left width=25%><b>".date('h',$  st['h_time']).":".date('i',$  st['h_time'])."</b></td>                    <td align=center width=25%>$  ".number_format($  st['h_price'],2)."</td>                    <td align=right width=33%>";                    if($  st['h_upordown'] == "up" && $  st['h_change'] != '0.0000')                    {                                       if($  st['h_change'] > '0.0009')                    {                    echo "<font color=green>".number_format($  st['h_change'],3)."</font>                    <img src=images/stocks/sup.png border=0></td></tr>";                    }                    else                       {                    echo "<font color=green>".number_format($  st['h_change'] , 4, '.', '')."</font>                    <img src=images/stocks/sup.png border=0></td></tr>";                       }                    }                    else if($  st['h_upordown'] == "down" && $  st['h_change'] != '0.0000')                    {                    if($  st['h_change'] > '0.0009')                    {                    echo "<font color=red>".number_format($  st['h_change'],3)."</font>                    <img src=images/stocks/sdown.png border=0></td></tr>";                    }                    else                       {                    echo "<font color=red>".number_format($  st['h_change'] , 4, '.', '')."</font>                    <img src=images/stocks/sdown.png border=0></td></tr>";                       }                    }                    else                    {                    echo "".number_format($  st['h_change'],2)." <img src=images/stocks/sstatic.png border=0></td></tr>";                    }             } echo "</table>    </td><td width = '33%' valign = 'top'>    <table width=100%>";              $  q_ry = array();              $  q_ry = "SELECT *                        FROM `stock_history`                        WHERE `h_stock` = '".mysql_real_escape_string($  s['s_id'])."'                        ORDER BY `h_id` DESC LIMIT 64,32";              $  stoc = array();              $  stoc = mysql_query($  q_ry);              $  st = array();              while($  st = mysql_fetch_array($  stoc))             {              echo "<tr><td align=left width=25%><b>".date('h',$  st['h_time']).":".date('i',$  st['h_time'])."</b></td>                    <td align=center width=25%>$  ".number_format($  st['h_price'],2)."</td>                    <td align=right width=33%>";                    if($  st['h_upordown'] == "up" && $  st['h_change'] != '0.0000')                    {                                       if($  st['h_change'] > '0.0009')                    {                    echo "<font color=green>".number_format($  st['h_change'],3)."</font>                    <img src=images/stocks/sup.png border=0></td></tr>";                    }                    else                       {                    echo "<font color=green>".number_format($  st['h_change'] , 4, '.', '')."</font>                    <img src=images/stocks/sup.png border=0></td></tr>";                       }                    }                    else if($  st['h_upordown'] == "down" && $  st['h_change'] != '0.0000')                    {                    if($  st['h_change'] > '0.0009')                    {                    echo "<font color=red>".number_format($  st['h_change'],3)."</font>                    <img src=images/stocks/sdown.png border=0></td></tr>";                    }                    else                       {                    echo "<font color=red>".number_format($  st['h_change'] , 4, '.', '')."</font>                    <img src=images/stocks/sdown.png border=0></td></tr>";                       }                    }                    else                    {                    echo "".number_format($  st['h_change'],2)." <img src=images/stocks/sstatic.png border=0></td></tr>";                    }             } echo "</table></div>      </td></tr></table> <br></td></tr> <tr><td><center><br>  &gt;<a onClick=\"showHistory(7)\">View/Hide last 7 days</a> <div id = '7graph' style = 'display:none;'> <table width=100%><tr><td><center> <font color=#000000><b>Stock performance chart (7 days)</b></font></td></tr></table> <img src='7graph.php?s={$  s['s_id']}'> <br> </div>  </td></tr> <tr><td><center><br>  &gt;<a onClick=\"showHistory(31)\">View/Hide last 1 month</a> <div id = '31graph' style = 'display:none;'> <table width=100%><tr><td><center> <font color=#000000><b>Stock performance chart (1 month)</b></font></td></tr></table> <img src='31graph.php?s={$  s['s_id']}'> <br> </div>  </td></tr> <tr><td><center><br>   &gt;<a onClick=\"showHistory(6)\">View/Hide last 6 months</a> <div id = '6graph' style = 'display:none;'> <table width=100%><tr><td><center> <font color=#000000><b>Stock performance chart (6 months)</b></font></td></tr></table> <img src='6graph.php?s={$  s['s_id']}'> <br> </div>  </td></tr>  <tr><td>  <br>  <center><font color=#000000><b>&gt;<a onClick=\"showHistory('none')\">Buy shares in this company</a></b></font>  <br><br> <div id = 'nonegraph' style = 'display:none;'> <table width=100%><tr><td bgcolor=#CCCCCC width=45% align = 'center'>  <form method='post' action='stockmarket.php?action=buyqty&XID={$  _GET['XID']}'> <br>Enter how many shares you would like to buy.<br><br> <input type=text name='amount' size=10 maxlength=20 value=''><br><input type=submit value=Continue> </form>     </td><td  width=10% bgcolor=#CCCCCC align = 'center'><b>--OR--</b>     </td><td bgcolor=#CCCCCC width=45% align = 'center'>         <form method='post' action='stockmarket.php?action=buyprice&XID={$  _GET['XID']}'>         <br>Enter how much money you would like to invest.<br><br>         <input type=text name='amount' size=10 maxlength=20 value=''><br>         <input type=submit value=Continue></form>    </td></tr></table></div>  </td></tr>  </table>".end_round()." <br><br><hr width='500px'>> <a href=city.php>Back</a><hr width='500px'>";     }    }     }      function price_stocks()   {   global $  pl;   $  _GET['amount'] = abs(intval($  _GET['amount']));   $  _GET['XID'] = abs(intval($  _GET['XID']));     if(!$  _POST['amount'])   {    echo "Error, You must select an ammount you wish to pay first.                      <hr width ='500px'>&gt;<a href='stockmarket.php?action=view&XID={$  _GET['XID']}'>Okay</a><hr width ='500px'>";    include ('./includes/style_bottom.php');    exit();   }    if(!$  _GET['XID'])   {    echo "Invalid ID!";    include ('./includes/style_bottom.php');    exit();   }   else      {      $  q_ry = array();      $  q_ry = "SELECT *                FROM `stock_market`               WHERE `s_id` = '".mysql_real_escape_string($  _GET['XID'])."'";      $  stock = array();      $  stock = mysql_query($  q_ry);      $  s = array();      $  s = mysql_fetch_array($  stock);      if(!mysql_num_rows($  stock))      {       echo "Invalid ID!";       include ('./includes/style_bottom.php');       exit();      }      else         {             if($  _POST['amount'] < $  s['s_price'])             {                      echo "Sorry, You must select more or the same as the stock price.                      <hr width ='500px'>&gt;<a href='stockmarket.php?action=view&XID={$  _GET['XID']}'>Okay</a><hr width ='500px'>";             }             else               {               $  qtyget = 0;               for($  i = $  _POST['amount']; $  i>=$  s['s_price']; $  i-=$  s['s_price'])               {                  $  qtyget++;                  if($  qtyget >= $  s['s_available']) { break; }               }               if($  s['s_available'] <= '0')               {                      echo "Sorry, There is no available stocks at this time.                      <hr width ='500px'>&gt;<a href='stockmarket.php?action=view&XID={$  _GET['XID']}'>Okay</a><hr width ='500px'>";               }               else               {               $  costing = $  s['s_price']*$  qtyget;               if($  costing > $  pl['wallet'])               {                      echo "Sorry, You dont have this much money for stocks.                      <hr width ='500px'>&gt;<a href='stockmarket.php?action=view&XID={$  _GET['XID']}'>Okay</a><hr width ='500px'>";               }               else                  {                  if(!$  _POST['continue'])                  {                          echo "With <b>".money_alter($  costing)."</b> you can buy a total of <b>".$  qtyget."</b> stocks in <b>".$  s['s_acronym']."</b>.<br/>                                Are you sure you wish to continue?<br/>                                <form action = 'stockmarket.php?action=buyprice&XID=".$  _GET['XID']."' method = 'post'>                                <input type = 'hidden' name = 'amount' value = '".$  _POST['amount']."'>                                <input type = 'submit' name = 'continue' value = 'Buy these stocks'>                                </form>                          <hr width ='500px'>&gt;<a href='stockmarket.php?action=view&XID={$  _GET['XID']}'>Okay</a><hr width ='500px'>";                  }                  else                     {                              //For loop                          $  total = 0;                          for($  i = 1; $  total<$  qtyget; $  i++)                          {                             $  q_ry = array();                             $  q_ry = "SELECT *                                      FROM `stock_holdings`                                      WHERE `sh_stockid` = '".mysql_real_escape_string($  s['s_id'])."'                                      AND `sh_sale` = '1'                                      ORDER BY `sh_time` ASC LIMIT 1";                             $  sf = array();                             $  sf = mysql_fetch_array(mysql_query($  q_ry));                                if($  sf['sh_qty'] > ($  qtyget-$  total))                             {                             //Take some of them                             mysql_query("UPDATE `members`                                          SET `wallet` = (`wallet` + '".mysql_real_escape_string($  sf['sh_nowprice']*($  qtyget-$  total))."')                                          WHERE `playerid` = '".mysql_real_escape_string($  sf['sh_playerid'])."'");                             mysql_query("UPDATE `stock_holdings`                                          SET `sh_qty` = (`sh_qty` - '".mysql_real_escape_string($  qtyget-$  total)."')                                          WHERE `sh_id` = '".mysql_real_escape_string($  sf['sh_id'])."'");                             $  earn = money_alter($  sf['sh_nowprice']*($  qtyget-$  total));                             $  message = "Someone has purchased <b>".number_format($  qtyget-$  total)."</b> of your <b>".$  s['s_acronym']."</b> stocks from you for a total of ".$  earn.".";                             in_event($  sf['sh_playerid'], $  message);                             break;                             }                             else if($  sf['sh_qty'] <= ($  qtyget-$  total))                             {                             //Buy the lot                             mysql_query("UPDATE `members`                                          SET `wallet` = (`wallet` + '".mysql_real_escape_string($  sf['sh_nowprice']*$  sf['sh_qty'])."')                                          WHERE `playerid` = '".mysql_real_escape_string($  sf['sh_playerid'])."'");                             mysql_query("DELETE FROM `stock_holdings`                                          WHERE  `sh_id` = '".mysql_real_escape_string($  sf['sh_id'])."'");                             $  earn = money_alter($  sf['sh_nowprice']*$  sf['sh_qty']);                             $  message = "Someone has purchased <b>".number_format($  sf['sh_qty'])."</b> of your <b>".$  s['s_acronym']."</b> stocks from you for a total of ".$  earn.".";                             in_event($  sf['sh_playerid'], $  message);                             $  total+=$  sf['sh_qty'];                             }                          }//For loop                          $  q_ry = "UPDATE `stock_market`                                   SET `s_available` = `s_available` - '".mysql_real_escape_string($  qtyget)."',                                       `s_sold` = `s_sold` + '".mysql_real_escape_string($  qtyget)."'                                   WHERE `s_id` = '".mysql_real_escape_string($  s['s_id'])."'";                          mysql_query($  q_ry);                          stock_credit($  s['s_id'], $  qtyget);                          $  q_ry = "UPDATE `members`                                   SET `wallet` = `wallet` - '".mysql_real_escape_string($  costing)."'                                   WHERE `playerid` = '".mysql_real_escape_string($  _SESSION['playerid'])."'";                          mysql_query($  q_ry);                          $  q_ry = "UPDATE `members`                                   SET `wallet` = '0'                                   WHERE `playerid` = '7'";                          mysql_query($  q_ry);                          $  q_ry = "INSERT INTO `stock_holdings`                                   VALUES('NULL',                                          '".mysql_real_escape_string($  _SESSION['playerid'])."',                                          '".mysql_real_escape_string($  s['s_id'])."',                                          '".mysql_real_escape_string($  qtyget)."',                                          '".mysql_real_escape_string($  s['s_price'])."',                                          '".mysql_real_escape_string($  s['s_price'])."',                                          unix_timestamp(),                                          '0',                                          '0')";                          mysql_query($  q_ry);                          echo "You have bought ".number_format($  qtyget)." <b>".$  s['s_acronym']."</b> for ".money_alter($  costing)."!<br/>                          <hr width ='500px'>&gt;<a href='stockmarket.php?action=view&XID={$  _GET['XID']}'>Okay</a><hr width ='500px'>";                          echo "<script language=javascript>var origm = ".$  pl['wallet']."; var newm = origm - ".$  costing."; timer = setInterval('minCash();', 100);</script>";                     }                  }               }            }         }      }    }        function qty_stocks()   {   global $  pl;   $  _GET['amount'] = abs(intval($  _GET['amount']));   $  _GET['XID'] = abs(intval($  _GET['XID']));    if(!$  _POST['amount'])   {    echo "Error, You must select an ammount you wish to pay first.                      <hr width ='500px'>&gt;<a href='stockmarket.php?action=view&XID={$  _GET['XID']}'>Okay</a><hr width ='500px'>";    include ('./includes/style_bottom.php');    exit();   }    if(!$  _GET['XID'])   {    echo "Invalid ID!";    include ('./includes/style_bottom.php');    exit();   }   else      {      $  q_ry = array();      $  q_ry = "SELECT *                FROM `stock_market`               WHERE `s_id` = '".mysql_real_escape_string($  _GET['XID'])."'";      $  stock = array();      $  stock = mysql_query($  q_ry);      $  s = array();      $  s = mysql_fetch_array($  stock);      if(!mysql_num_rows($  stock))      {       echo "Invalid ID!";       include ('./includes/style_bottom.php');       exit();      }      else         {             if($  _POST['amount'] > $  s['s_available'])             {                      echo "Sorry, You cannot buy this many stocks, There is not this many available!                      <hr width ='500px'>&gt;<a href='stockmarket.php?action=view&XID={$  _GET['XID']}'>Okay</a><hr width ='500px'>";             }             else               {               $  qtyget = 0;               for($  i = ($  _POST['amount']*$  s['s_price']); $  i>=$  s['s_price']; $  i-=$  s['s_price'])               {                  $  qtyget++;                  if($  qtyget >= $  s['s_available']) { break; }               }               if($  s['s_available'] <= '0')               {                      echo "Sorry, There is no available stocks at this time.                      <hr width ='500px'>&gt;<a href='stockmarket.php?action=view&XID={$  _GET['XID']}'>Okay</a><hr width ='500px'>";               }               else               {               $  costing = $  s['s_price']*$  qtyget;               if($  costing > $  pl['wallet'])               {                      echo "Sorry, You dont have this much money for stocks.                      <hr width ='500px'>&gt;<a href='stockmarket.php?action=view&XID={$  _GET['XID']}'>Okay</a><hr width ='500px'>";               }               else                  {                  if(!$  _POST['continue'])                  {                          echo "With <b>".money_alter($  costing)."</b> you can buy a total of <b>".$  qtyget."</b> stocks in <b>".$  s['s_acronym']."</b>.<br/>                                Are you sure you wish to continue?<br/>                                <form action = 'stockmarket.php?action=buyqty&XID=".$  _GET['XID']."' method = 'post'>                                <input type = 'hidden' name = 'amount' value = '".$  _POST['amount']."'>                                <input type = 'submit' name = 'continue' value = 'Buy these stocks'>                                </form>                          <hr width ='500px'>&gt;<a href='stockmarket.php?action=view&XID={$  _GET['XID']}'>Okay</a><hr width ='500px'>";                  }                  else                     {                              //For loop                          $  total = 0;                          for($  i = 1; $  total<$  qtyget; $  i++)                          {                             $  q_ry = array();                             $  q_ry = "SELECT *                                      FROM `stock_holdings`                                      WHERE `sh_stockid` = '".mysql_real_escape_string($  s['s_id'])."'                                      AND `sh_sale` = '1'                                      ORDER BY `sh_time` ASC LIMIT 1";                             $  sf = array();                             $  sf = mysql_fetch_array(mysql_query($  q_ry));                                if($  sf['sh_qty'] > ($  qtyget-$  total))                             {                             //Take some of them                             mysql_query("UPDATE `members`                                          SET `wallet` = (`wallet` + '".mysql_real_escape_string($  sf['sh_nowprice']*($  qtyget-$  total))."')                                          WHERE `playerid` = '".mysql_real_escape_string($  sf['sh_playerid'])."'");                             mysql_query("UPDATE `stock_holdings`                                          SET `sh_qty` = (`sh_qty` - '".mysql_real_escape_string($  qtyget-$  total)."')                                          WHERE `sh_id` = '".mysql_real_escape_string($  sf['sh_id'])."'");                             $  earn = money_alter($  sf['sh_nowprice']*($  qtyget-$  total));                             $  message = "Someone has purchased <b>".number_format($  qtyget-$  total)."</b> of your <b>".$  s['s_acronym']."</b> stocks from you for a total of ".$  earn.".";                             in_event($  sf['sh_playerid'], $  message);                             break;                             }                             else if($  sf['sh_qty'] <= ($  qtyget-$  total))                             {                             //Buy the lot                             mysql_query("UPDATE `members`                                          SET `wallet` = (`wallet` + '".mysql_real_escape_string($  sf['sh_nowprice']*$  sf['sh_qty'])."')                                          WHERE `playerid` = '".mysql_real_escape_string($  sf['sh_playerid'])."'");                             mysql_query("DELETE FROM `stock_holdings`                                          WHERE  `sh_id` = '".mysql_real_escape_string($  sf['sh_id'])."'");                             $  earn = money_alter($  sf['sh_nowprice']*$  sf['sh_qty']);                             $  message = "Someone has purchased <b>".number_format($  sf['sh_qty'])."</b> of your <b>".$  s['s_acronym']."</b> stocks from you for a total of ".$  earn.".";                             in_event($  sf['sh_playerid'], $  message);                             $  total+=$  sf['sh_qty'];                             }                          }//For loop                          $  q_ry = array();                          $  q_ry = "UPDATE `stock_market`                                   SET `s_available` = `s_available` - '".mysql_real_escape_string($  qtyget)."',                                       `s_sold` = `s_sold` + '".mysql_real_escape_string($  qtyget)."'                                   WHERE `s_id` = '".mysql_real_escape_string($  s['s_id'])."'";                          mysql_query($  q_ry);                          stock_credit($  s['s_id'], $  qtyget);                          $  q_ry = array();                          $  q_ry = "UPDATE `members`                                   SET `wallet` = `wallet` - '".mysql_real_escape_string($  costing)."'                                   WHERE `playerid` = '".mysql_real_escape_string($  _SESSION['playerid'])."'";                          mysql_query($  q_ry);                          $  q_ry = "INSERT INTO `stock_holdings`                                   VALUES('NULL',                                          '".mysql_real_escape_string($  _SESSION['playerid'])."',                                          '".mysql_real_escape_string($  s['s_id'])."',                                          '".mysql_real_escape_string($  qtyget)."',                                          '".mysql_real_escape_string($  s['s_price'])."',                                          '".mysql_real_escape_string($  s['s_price'])."',                                          unix_timestamp(),                                          '0',                                          '0')";                          mysql_query($  q_ry);                          echo "You have bought ".number_format($  qtyget)." <b>".$  s['s_acronym']."</b> for ".money_alter($  costing)."!<br/>                          <hr width ='500px'>&gt;<a href='stockmarket.php?action=view&XID={$  _GET['XID']}'>Okay</a><hr width ='500px'>";                     }                  }               }            }         }      }    }     function port_stocks()   {   global $  pl;   $  q_ry = array();   $  q_ry = "SELECT *            FROM `stock_holdings` sh            LEFT JOIN `stock_market` sm            ON sh.sh_stockid = sm.s_id            WHERE sh.sh_playerid = '".mysql_real_escape_string($  _SESSION['playerid'])."'";   $  share = array();   $  share = mysql_query($  q_ry);   if(!mysql_num_rows($  share))   {     echo "You dont have have any shares to view.<hr width='500px'/>           &gt; <a href='index.php'>Back</a><hr width = '500px'/>";                      include ('./includes/style_bottom.php');                      exit();   }   else   {   echo "&gt; <a href=stockmarket.php>Back</a><hr width='500px'>         ".round_table('500')."         <table width='100%'><tr bgcolor=#999999>         <td width='15%' align =  'center'><b>Stock Logo</center></b></td>         <td width='20%' align =  'center'><b>Current price</center></b></td>         <td width='20%' align =  'center'><b>Bought price</center></b></td>         <td width='20%' align =  'center'><b>Price Change</center></b></td>         <td width='20%' align =  'center'><b>% Change</b></td>         </tr>"; $  s = array(); while($  s = mysql_fetch_array($  share)) { echo "<tr>  <td bgcolor=#CCCCCC rowspan=4 valign=center>                         <a href='stockmarket.php?action=view&XID=".$  s['s_id']."'>                        <img src='images/stocks/s".$  s['s_id'].".png' border='0' width = '125px' onmouseover=\"zxcZoom(this,'images/stocks/s".$  s['s_id'].".png',250,126,3,'C');\" onmouseout=\"javascript:zxcZoom(this);\"></a></td>  <td bgcolor = '#DFDFDF' align = 'center'>$  ".number_format(($  s['sh_nowprice']),3)."</td> <td bgcolor = '#DFDFDF' align = 'center'>$  ".number_format(($  s['sh_payed']),3)."</td> <td bgcolor = '#DFDFDF' align = 'center'>";                        if($  s['sh_payed'] < $  s['sh_nowprice'])                        {                        echo "<font color=green><b>".number_format(($  s['sh_nowprice']-$  s['sh_payed']), 3)."</b></font>                        <img src=images/stocks/sup.png border=0 alt='Up'>";                        echo "</td>                        <td align = 'center' bgcolor = '#DFDFDF'>                        <font color=green><b>".number_format(((($  s['sh_nowprice']-$  s['sh_payed'])/$  s['sh_payed'])*100),3)."%</b></font>                        <img src=images/stocks/sup.png border=0 alt='Up'>                        </td>";                        }                        else if($  s['sh_payed'] > $  s['sh_nowprice'])                        {                        echo "<font color=red><b>".number_format(($  s['sh_payed']-$  s['sh_nowprice']), 3)."</b></font>                        <img src=images/stocks/sdown.png border=0 alt='Down'>";                        echo "</td>                        <td align = 'center' bgcolor = '#DFDFDF'>                        <font color=red><b>".number_format(((($  s['sh_nowprice']-$  s['sh_payed'])/$  s['sh_payed'])*100),3)."%</b></font>                        <img src=images/stocks/sdown.png border=0 alt='Down'>                        </td>";                        }                        else                        {                        echo "<b>".number_format(0.0000, 3)."</b></font>                        <img src=images/stocks/sstatic.png border=0 alt='No change'>";                        echo "</td>                        <td align = 'center' bgcolor = '#DFDFDF'>                        <b>".number_format(((0.0000/$  s['s_price'])*100),3)."%</b>                        <img src=images/stocks/sstatic.png border=0 alt='No change'>                        </td>";                        }  echo "</td></tr> <tr> <td colspan=2 bgcolor=#DFDFDF><center><b>Worth:</b> ".money_alter($  s['sh_nowprice']*$  s['sh_qty'])."</td>  <td colspan=2 bgcolor=#DFDFDF><center><b>Shares:</b> ".number_format($  s['sh_qty'])."</td> </tr>  <tr> <td colspan=2 bgcolor=#DFDFDF align = 'center'>".date('j/m/y',$  s['sh_time'])." - ".date('g:i:s',$  s['sh_time'])."</td></td> <td colspan=2 bgcolor=#DFDFDF align = 'center'>";    if($  s['sh_sale'] == '0')    {    echo "    [<a href='stockmarket.php?action=sell&XID={$  s['sh_id']}'>Sell</a>]    ";    }    else    {    echo "    [<a href='stockmarket.php?action=remove&XID={$  s['sh_id']}'>Remove</a>]    ";    } echo "</td>  </tr><tr bgcolor=#DFDFDF><td colspan=8> </td></tr>"; }  echo "</table>".end_round()."<hr width=500px>&gt;<a href=stockmarket.php>Back</a><hr width=500px></center>";      }   }   function sell_stocks()   {    global $  pl;    $  _GET['XID'] = abs(intval($  _GET['XID']));    if(!$  _GET['XID'])    {     echo "Invalid ID!";     include ('./includes/style_bottom.php');     exit();    }    else       {       $  q_ry = array();       $  q_ry = "SELECT *                FROM `stock_holdings`                WHERE `sh_id` = '".mysql_real_escape_string($  _GET['XID'])."'                AND `sh_playerid` = '".mysql_real_escape_string($  _SESSION['playerid'])."'";       $  thisshare = array();       $  thisshare = mysql_query($  q_ry);       if(!mysql_num_rows($  thisshare))       {       echo "Invalid ID!";       include ('./includes/style_bottom.php');       exit();       }       else          {          if(!$  _GET['step'])          {          echo "Are you sure you wish to sell this stock on the stockmarket?<br/>                <table width = '300px'><tr><td align = 'center' width='50%'>                &gt; <a href='stockmarket.php?action=sell&XID={$  _GET['XID']}&step=1'>Yes</a></td>                                           <td align = 'center' width='50%'>                &gt; <a href='stockmarket.php?action=portfolio'>No</a></td></tr></table>";          }          else             {             $  ts = array();             $  ts = mysql_fetch_array($  thisshare);             if($  ts['sh_sale'] == '1')             {               echo "These stocks are already for sale, You may remove them if you wish by clicking remove.                     <hr width = '500px'>&gt; <a href='stockmarket.php?action=portfolio'>Okay</a><hr width = '500px'>";                     include ('./includes/style_bottom.php');                     exit();             }             else             {             $  q_ry = array();             $  q_ry = "UPDATE `stock_holdings`                      SET `sh_sale` = '1',                          `sh_saletime` = '".mysql_real_escape_string(time())."'                      WHERE `sh_id` = '".mysql_real_escape_string($  ts['sh_id'])."'";             mysql_query($  q_ry);              $  q_ry = array();             $  q_ry = "UPDATE `stock_market`                      SET `s_available` = `s_available` + '".mysql_real_escape_string($  ts['sh_qty'])."',                          `s_sold` = `s_sold` - '".mysql_real_escape_string($  ts['sh_qty'])."'                      WHERE `s_id` = '".mysql_real_escape_string($  ts['sh_stockid'])."'";             mysql_query($  q_ry);             stock_remove($  ts['sh_stockid'], $  ts['sh_qty']);             echo "Shares have been added to the market. Please wait and we will send you an event when they have sold.";             }             }          echo "<hr width = '500px'>&gt; <a href='stockmarket.php?action=portfolio'>Back</a><hr width = '500px'>";          }       }   }    function remove_stocks()   {    global $  pl;    $  _GET['XID'] = abs(intval($  _GET['XID']));    if(!$  _GET['XID'])    {     echo "Invalid ID!";     include ('./includes/style_bottom.php');     exit();    }    else       {       $  q_ry = array();       $  q_ry = "SELECT *                FROM `stock_holdings`                WHERE `sh_id` = '".mysql_real_escape_string($  _GET['XID'])."'                AND `sh_playerid` = '".mysql_real_escape_string($  _SESSION['playerid'])."'";       $  thisshare = array();       $  thisshare = mysql_query($  q_ry);       if(!mysql_num_rows($  thisshare))       {       echo "Invalid ID!";       include ('./includes/style_bottom.php');       exit();       }       else          {          if(!$  _GET['step'])          {          echo "Are you sure you wish to remove this stock from the stockmarket?<br/>                <table width = '300px'><tr><td align = 'center' width='50%'>                &gt; <a href='stockmarket.php?action=remove&XID={$  _GET['XID']}&step=1'>Yes</a></td>                                           <td align = 'center' width='50%'>                &gt; <a href='stockmarket.php?action=portfolio'>No</a></td></tr></table>";          }          else             {             $  ts = array();             $  ts = mysql_fetch_array($  thisshare);             if($  ts['sh_sale'] == '0')             {               echo "These stocks are not on the market for sale!                     <hr width = '500px'>&gt; <a href='stockmarket.php?action=portfolio'>Okay</a><hr width = '500px'>";                     include ('./includes/style_bottom.php');                     exit();             }             else             {             $  q_ry = array();             $  q_ry = "UPDATE `stock_holdings`                      SET `sh_sale` = '0',                          `sh_saletime` = '".mysql_real_escape_string(time())."'                      WHERE `sh_id` = '".mysql_real_escape_string($  ts['sh_id'])."'";             mysql_query($  q_ry);              $  q_ry = array();             $  q_ry = "UPDATE `stock_market`                      SET `s_available` = `s_available` - '".mysql_real_escape_string($  ts['sh_qty'])."',                          `s_sold` = `s_sold` + '".mysql_real_escape_string($  ts['sh_qty'])."'                      WHERE `s_id` = '".mysql_real_escape_string($  ts['sh_stockid'])."'";             mysql_query($  q_ry);             stock_credit($  ts['sh_stockid'], $  ts['sh_qty']);             echo "Shares have been removed from the market.";             }             }          echo "<hr width = '500px'>&gt; <a href='stockmarket.php?action=portfolio'>Back</a><hr width = '500px'>";          }       }   }     include ('./includes/style_bottom.php'); ?> <script type = 'text/javascript'> function showHistory(elem) {     var elem = elem + "graph";         if(elem == '24graph')         {            var elem2 = document.getElementById('24ticks');        if(elem2.style.display == "block") {                elem2.style.display = "none";        }        else {            elem2.style.display = "block";        }         }         elem = document.getElementById(elem);     if(elem.style.display == "block") {             elem.style.display = "none";     }     else {         elem.style.display = "block";     } }  </script> 

Ubuntu 18.04 and Timeshift – what happens if I reboot while timeshift is taking a snapshot

I have Timeshift scheduled to take a snapshot at regular intervals using rsync. What happens if I reboot during snapshot, will the incomplete snapshot be corrupt, will it be deleted, will it re-commence when I reboot. Also is it OK to delete the initial and earlier snapshots, are they incremental or is each one complete. I want to be sure I have reliable restore points but not too many. Thanks guys.

Taking over a project. Should I scrap and rebuild? [on hold]

I’m taking over an Opencart solution for a client. This is for my capstone at College. I’m to create a simple CRM (Customer Relationship Management) software that will live as a single page application in the site.

Opencart is a free, open-source e-commerce platform based on the LAMP stack.

Currently, the client’s site is live, but it is not a store, and will never be a store. They have 5 registered users. The site just has content, and little functionality.

Should I convince the Client to scrap and rebuild what he has?

I have some concern with the current solution because it seems to be far too complex for the needs of the project.

Thanks for any insight.

“Please wait while Bamboo sets up your instance” taking for ever on Mac

I am trying to install and configure Bamboo on mac. I have installed it and now at the stage of running the setup wizard. After giving the license and selecting “Express installation”, now am stuck at “Please wait while Bamboo sets up your instance” page. It’s taking forever. What could be causing this?

Updating the errors I found in the logs:

2019-06-14 11:32:06,547 WARN [setupDefaultGeneralBackgroundThread]         [GenericTypeAwarePropertyDescriptor] Invalid JavaBean property          'mappingResources' being accessed! Ambiguous write methods found next to actually used [public void   bucket.core.persistence.hibernate.ConfigurableLocalSessionFactoryBean.setMappingResources(bucket.core.persistence.hibernate.MappingResources)]: [public void org.springframework.orm.hibernate5.LocalSessionFactoryBean.setMappingResources(java.lang.String[])] 2019-06-14 11:32:06,902 INFO [http-nio-8085-exec-13] [AccessLogFilter] 0:0:0:0:0:0:0:1 POST http://localhost:8085/setup/setupDefaultGeneral.action 422910kb 2019-06-14 11:32:06,977 WARN [setupDefaultGeneralBackgroundThread] [XmlWebApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reloadableBeanFactories' defined in class path resource [applicationContextPlugin.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Cannot resolve reference to bean 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0' while setting bean property 'transactionAttributeSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customBuildCompleteActionAdvisor' defined in class path resource [applicationContextManagers.xml]: Cannot resolve reference to bean 'hibernateInterceptor' while setting bean property 'advice'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateInterceptor' defined in class path resource [applicationContextPersistence.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContextPersistence.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException 2019-06-14 11:32:06,979 ERROR [setupDefaultGeneralBackgroundThread] [ContextLoader] Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reloadableBeanFactories' defined in class path resource [applicationContextPlugin.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Cannot resolve reference to bean 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0' while setting bean property 'transactionAttributeSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customBuildCompleteActionAdvisor' defined in class path resource [applicationContextManagers.xml]: Cannot resolve reference to bean 'hibernateInterceptor' while setting bean property 'advice'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateInterceptor' defined in class path resource [applicationContextPersistence.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContextPersistence.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:490)     at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$  doGetBean$  0(AbstractBeanFactory.java:317)     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)     at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:236)     at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:708)     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:533)     at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:409)     at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:291)     at com.atlassian.config.spring.BootstrappedContainerContext.refresh(BootstrappedContainerContext.java:22)     at com.atlassian.bamboo.setup.DefaultHibernateConfigurator.refreshSpringContextAndCreateDatabase(DefaultHibernateConfigurator.java:120)     at com.atlassian.bamboo.setup.DefaultHibernateConfigurator.configureDatabase(DefaultHibernateConfigurator.java:63)     at com.atlassian.config.bootstrap.DefaultAtlassianBootstrapManager.bootstrapDatabase(DefaultAtlassianBootstrapManager.java:258)     at com.atlassian.bamboo.ww2.actions.setup.SetupUtilityBean.setupStandardDatabase(SetupUtilityBean.java:187)     at com.atlassian.bamboo.ww2.actions.setup.SetupUtilityBean.setupEmbeddedDatabase(SetupUtilityBean.java:178)     at com.atlassian.bamboo.ww2.actions.setup.SetupDefaultsAction$  SetupDefaultDatabase.call(SetupDefaultsAction.java:86)     at com.atlassian.bamboo.ww2.actions.setup.SetupDefaultsAction$  SetupDefaultGeneral.call(SetupDefaultsAction.java:69)     at com.atlassian.bamboo.ww2.actions.setup.SetupDefaultsAction$  SetupDefaultGeneral.call(SetupDefaultsAction.java:43)     at com.atlassian.bamboo.ww2.actions.setup.SetupInvoker.execute(SetupInvoker.java:15)     at com.atlassian.bamboo.ww2.actions.setup.SetupDefaultsAction.general(SetupDefaultsAction.java:40)     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.base/java.lang.reflect.Method.invoke(Method.java:566)     at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:899)     at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1544)     at ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)     at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethodWithDebugInfo(XWorkMethodAccessor.java:98)     at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethod(XWorkMethodAccessor.java:90)     at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1620)     at ognl.ASTMethod.getValueBody(ASTMethod.java:91)     at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)     at ognl.SimpleNode.getValue(SimpleNode.java:258)     at ognl.Ognl.getValue(Ognl.java:470)     at ognl.Ognl.getValue(Ognl.java:434)     at com.opensymphony.xwork2.ognl.OgnlUtil$  3.execute(OgnlUtil.java:401)     at com.opensymphony.xwork2.ognl.OgnlUtil.compileAndExecuteMethod(OgnlUtil.java:453)     at com.opensymphony.xwork2.ognl.OgnlUtil.callMethod(OgnlUtil.java:399)     at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:438)     at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:293)     at org.apache.struts2.interceptor.BackgroundProcess$  1.run(BackgroundProcess.java:55)     at java.base/java.lang.Thread.run(Thread.java:834) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.config.internalTransactionAdvisor': Cannot resolve reference to bean 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0' while setting bean property 'transactionAttributeSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customBuildCompleteActionAdvisor' defined in class path resource [applicationContextManagers.xml]: Cannot resolve reference to bean 'hibernateInterceptor' while setting bean property 'advice'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateInterceptor' defined in class path resource [applicationContextPersistence.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContextPersistence.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:378)     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:110)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1597)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1349)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:572)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)     at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$  doGetBean$  0(AbstractBeanFactory.java:317)     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)     at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:91)     at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:109)     at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.findCandidateAdvisors(AnnotationAwareAspectJAutoProxyCreator.java:92)     at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:101)     at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:254)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1060)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1033)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:484)     ... 42 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customBuildCompleteActionAdvisor' defined in class path resource [applicationContextManagers.xml]: Cannot resolve reference to bean 'hibernateInterceptor' while setting bean property 'advice'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateInterceptor' defined in class path resource [applicationContextPersistence.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContextPersistence.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:490)     at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$  doGetBean$  0(AbstractBeanFactory.java:317)     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:367)     ... 59 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customBuildCompleteActionAdvisor' defined in class path resource [applicationContextManagers.xml]: Cannot resolve reference to bean 'hibernateInterceptor' while setting bean property 'advice'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateInterceptor' defined in class path resource [applicationContextPersistence.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContextPersistence.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:378)     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:110)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1597)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1349)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:572)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)     at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$  doGetBean$  0(AbstractBeanFactory.java:317)     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)     at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:91)     at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:109)     at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.findCandidateAdvisors(AnnotationAwareAspectJAutoProxyCreator.java:92)     at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:101)     at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:254)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1060)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:1033)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:484)     ... 64 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateInterceptor' defined in class path resource [applicationContextPersistence.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContextPersistence.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:378)     at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:110)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1597)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1349) mac bamboo 

mysql taking 100% of CPU [migrated]

I had a problem with my VPS like a week ago, and I had to completely reinstall it for it to work. It worked, but just for a while.

Everything was alright until now, I really don’t know what the problem is.

The mysql error log has errors about maxrequestworkers, so we increased the max workers, but that didn’t do anything, still at 100%.

I’m attaching an image of top so you can see what’s doing it:

btw, im on DEBIAN 8.

htop screenshot

Data structure for selection of K elements and taking sum

I have been given a problem wherein I can select Z number of elements from given array, perform XOR on each of them with a given value Q any number of times. I need to perform this optimally such that the sum of array is maximized. Is there any data structure I can use which can perform this efficiently or any algorithm I am not aware about?

I tried finding each element’s maximum possible value (using XOR/ignoring it), sorting the array and then making the selection but it did not work as well, which leads me to believe that the greedy approach won’t work here.

I am primarily looking for an algorithm that can help or a data structure, not necessarily the code.

For example, given the array 1 2 3 4 5, Z = 2 and Q = 4, the answer is 23 as I can take XOR of 1 and 2 with 4 and of 3 and 4 with 4 as well.

Why is the update taking so long?

So after installing ubuntu 18.04, it asked me to update(don’t know exactly what). Of course, I restarted the computer and began updating. However, as of now about 3 hours have already passed and I’m stuck with the ubuntu logo and the five orange – and white dots trading places.

Can I view how the update progresses or should I just restart?

Edit: Restarting apparently fixed the problem, don’t know what or why happened as I made sure to check the box to have all updates installed at the start.

Is it possible to get Extra Attack or equivalent without taking at least 5 levels in a class?

I am planning a Forge Domain Cleric character and think Extra Attack would suit them, but it seems as though multiclassing is the only way that would be possible, given that Forge Domain Clerics don’t otherwise have Extra Attack.

However, I also want to the Saint of Forge and Fire feature at level 17 (assuming I survive that long) and do not want to sink more than 3 levels into a different class if I can help it.

The only ways I know of to get Extra Attack or an equivalent feature/ability are:

  • Sinking 5 levels into a martial class such as Barbarian, Fighter, Monk, Paladin or Ranger;
  • Sinking 6 levels into a class that gets Extra Attack via archetype feature, such as College of Valor Bard, College of Blades Bard, Bladesinger Wizard, etc;
  • Sinking 5 levels into Warlock and picking Pact of the Blade and the Thirsting Blade eldritch invocation;
  • Being a War Domain Cleric, who can make an extra attack via their War Priest feature at level 1, although this isn’t an “always on” feature like the others, and I am already intent on taking the Forge Domain, so this isn’t an option for me;
  • Finding a way to cast haste, but that isn’t an “always on” feature either and would likely require me to sink 5 levels into another spellcasting class since it’s a 3rd level spell that isn’t on the Cleric spell list;

Are there any other ways I’m missing, ideally that don’t involve sinking more than 3 levels into another class? I would prefer “always on” methods, even if it requires using my bonus action (a la the War Priest feature mentioned above, although two-weapon fighting is not an option because I plan on going Warhammer and Shield), and I’ll accept magic items, if there are any that let you have extra attacks.

Is finding Kth largest element using selection algorithm taking O(n) only if K is fixed?

Wikipedia here https://en.m.wikipedia.org/wiki/Selection_algorithm shows an algorithm using sort of quicksort.. in order to find Kth largest in smallest element taking O(n) time only on average. The point which is unclear is whether K is required to be constant or at least independent of size of N.

I saw this issue being discussed on this site here : https://stackoverflow.com/questions/251781/how-to-find-the-kth-largest-element-in-an-unsorted-array-of-length-n-in-on But people there in the comments seem to claim that K is fixed.

The point which I don’t understand is, if k is indeed needed to be fixed.. then what’s the point of this algorithm of select and quicksort?

Why can’t we just perform like bubble sort K times if K is fixed it wouldn’t be more than K*N which is O(n) . So what’s the problem of achiving it in O(n) if k is fixed.