I'm using Netbeans 8.0.2 (PHP edition) in Yosemite. I've been noticing a high memory usage of the application - for instance, I've checked Activity Monitor now and it was using more than 9GB of RAM! After closing and re-opening it is using less than 1GB.
I'm not doing any big project at the moment; indeed my projects are all small to medium. About the plugins, I use only xdebug, nothing fancy here.
I've noticed that the more time Netbeans is open, more memory it will use. The memory usage seems to increase each time i run or debug the project, so it seems some kind of memory leak.
What could be causing such a ridiculous memory usage?
Thanks!
You can edit netbeans.conf (located in "etc" subdir on wherever you installed netbeans), and pass -Xmx parameter, as documented on netbeans.conf itself. Note that if you don't pass this option then by default it will compute a maximum itself as a (big) fraction of your total ram. If you have lots of ram, them this maximum will also be huge, and depending on the jvm version and other parameters, java won't give memory back to the system easily or at all, so you probably want to put a very low bar on it. I leave mine with 1gb of ram and it never complained, but YMMV.
I have the same problem using an Wordpress project. Have you found out if it is some plugin?
I've a pretty standard installation having installed and using the emmet/zen coding. I know that this plugin had been problematic in the past. Do you have it installed?
Best regards.
Related
i am running the single core 512MB DO(digital ocean) droplet and Cent OS 6 i have configured php to use mod_suphp for security reasons. i will be running multiple sites off this box at some point, i want to isolate them all from eachother. the suphp setup went perfectly, i was able to install wordpress and set up the databases, ftp etc. the issue i am having is that certain actions spike the php-cgi process up to 100% and eventually timeout. the wordpress customizer hangs on save while accessing the admin-ajax.php file. one of the themes i was using (the X theme) when trying to upload a json file ended up hanging and timing out on line 30 of wp-includes/compat.php on cpanel servers, i used suphp without any issue, and the same actions and themes work fine. the only difference i notice is that the php process on cpanel machines is "php" whereas mine is "php-cgi". i have no idea if this is part of the issue, but any help at identifying why and how only certain wordpress scripts are overloading the cpu would be helpful. an important note is that the site is not under any traffic when this happens, as it is only in development. also there is just over 50% of the RAM used while the CPU is spiking so i am not running out of memory
SuPHP processes the file every single time it is called, due to this, it causes a lot of CPU usage. SuPHP just in general uses a lot of CPU, adding WordPress to the mix just makes the CPU usage even more. I recommend using FastCGI as your PHP handler as it uses a low amount of CPU but a high amount of memory. In addition you will be able to use OPCode caching such as APC or memcached, causing WordPress to be significantly faster. In regards to your security concern, FastCGI has the same security as SuPHP and you can upload things no problem. One small thing to note though is your going to need to tweak the settings quite a bit before you get it right, there will be errors at first possibly, the answers to all of which you can get courtesy of Google. Also, I am not sure how DO operates but if you need to fix permissions and have Cpanel, here is a nice article: http://boomshadow.net/tech/fixes/fixperms-script/
I'm a PHP developer and I use Eclipse on Mac (through Java VM), however - it seems to be very slow responsive when working with large source files (sometimes it is inevitable to edit such files).
That forces me to open subject file in some editor like TextMate or TextWrangler because these two handle large files much better than Eclipse.
I assume this is because Eclipse is driven on a Java VM, and probably TextMate and TextWrangler aren't (not sure though)?
Therefore, I'm wondering if someone could recommend some good IDE for PHP/JS for MAC OSX not based on Java VM (TextMate and/or TextWrangler are too narrowed to be used as IDE)? It is not important for such IDE to be freeware, as long as it is not too expensive.
Thanks in advance,
Radovan
Don't underestimate the power of TextMate. The Emacs style macros can do a lot very quickly. Still, aside from the intuitive shortcuts and macro's the program is rather "dumb".
Coda by Panic is a good step in the right direction. I usually alternate between the two depending on what I'm working on.
There's actually a lot of support for PHP related tasks in Dreamweaver but... it's Dreamweaver so, it has the same "fatty" problems that most Java based apps do.
There's a program call Espresso, I believe by macrabbit, that's rather similar to Coda, but in the brief time I gave it, preferred Coda.
XCode can handle PHP projects, but it's clearly not the right tool for the job. The file merge program that it comes with is very useful though.
OS X is really missing a clean, intuitive, cocoa based PHP/JS/CSS editor that includes things like code sense, macros, code folding, project management, version control integration. Coda's the best start IMHO, but still not a home run.
I don't know about non-JVM PHP IDEs, but loading big files is not an "intrinsic" problem of Java VM (the VM can handle big files as the same way as a native application, so the problem is not there.. how the IDE renders the editor could be another cause).
If you couldn't find a good non-Java VM alternative, there are some things that you could do to improve the performance with large files by change the JVM startup parameters used by Eclipse (you can do something similar for other Java based IDEs).
Show the package contents of your Eclipse.app and edit Contents/MacOS/eclipse.ini
At the end of that file you have JVM startup arguments you can look into the JVM documentation
A parameter that will affect the performance with large files is -Xmx which indicates the maximum memory available for the Java application, if the value is low or not present (the default is low for the IDE needs) your IDE will be slow because it spends a lot of time doing garbage collection (in Eclipse you can check if this is the problem by activating Eclipse->Preferences...->General / Show heap status -or something like that)
Here is an example of the startup parameters that I use for Eclipse (I'm using a MacBook with 4Gb of RAM):
-XX:PermSize=32m
-XX:MaxPermSize=384m
-Xms20m
-Xmx1024m
-Xss2m
-Xverify:none
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled
-Xverify:none turns off JVM bycode verification and makes Eclipse to load a little bit faster.
-Xms20m (is the initial heap size) is low.. the JVM will allocate more as needed, a big value maybe is better for other kinds of apps but in this case it makes Eclipse slower to load
-Xmx1024m use 1gb as maximum heap (I work with big Java projects and the heap never reached more than 600m)
I found my Mac Air battery was getting annihilated with Netbeans normally 8-10 hours usage down to about 1-2 with background scanning disabled, not good if your travelling!!
TextMate. Extremely lightweight,unnoticeable on consumption but has all the normal syntax features and GIT integration. When I'm not on my desktop this is the answer.
Joomla 1.5 - is enough 48MB memory in PHP settings ? or is better at least 64MB ?
I ask because sometime is realy slow respond.
Merax
Joomla is designed to run on the default 8M of memory that PHP.ini by default provides.
48 MB should be fine. Different from operating systems and classical applications that swap memory, increasing the memory limit in PHP will very rarely improve performance: If the memory limit is hit, the script usually simply crashes.
The reasons for the slowness of your site is most likely elsewhere, maybe on server level, maybe inside the Joomla application.
You may find the best resources on that in the Joomla community, which is very active. Googling turns up joomlaperformance.com which seems to have some articles.
When using netbeans to edit a PHP project, the IDE can (over time) use 400+ MB of memory. Is there any way to turn off certain features or other tricks to reduce its memory usage?
You can set the min & max memory limits via the netbeans.conf file.
Please, refer to the next faqs:
http://wiki.netbeans.org/FaqSlowNetBeans
http://wiki.netbeans.org/FaqNetBeansAndOOME
Haven't found any way to reduce either Eclipse and Netbeans. The problem is that javas JVM is using significant amout of memory to hold the compiled class representation. For example code is first compiled with something like -O0 for C compilers and later compiled with much better optimization if this is a frequently executed hotspot.
Thats why it is increasing over time. I don't know about any memory leak in Netbeans - so i guess it is just the program code and not the data set which is growing.
The way to reduce it is to remove unnecessary plugins.
But is this with the current prices for 4/8GB of RAM really a problem?
Does anybody have experience working with PHP accelerators such as MMCache or Zend Accelerator? I'd like to know if using either of these makes PHP comparable to faster web-technologies. Also, are there trade offs for using these?
Note that Zend Optimizer and MMCache (or similar applications) are totally different things. While Zend Optimizer tries to optimize the program opcode MMCache will cache the scripts in memory and reuse the precompiled code.
I did some benchmarks some time ago and you can find the results in my blog (in German though). The basic results:
Zend Optimizer alone didn't help at all. Actually my scripts were slower than without optimizer.
When it comes to caches:
* fastest: eAccelerator
* XCache
* APC
And: You DO want to install a opcode cache!
For example:
alt text http://blogs.interdose.com/dominik/wp-content/uploads/2008/04/opcode_wordpress.png
This is the duration it took to call the wordpress homepage 10.000 times.
Edit: BTW, eAccelerator contains an optimizer itself.
MMCache has been deprecated. I recommend either http://pecl.php.net/package/APC or http://xcache.lighttpd.net/, both of which also give you variable storage (like Memcache).
Both are interesting and will provide speed boost since they compile source code into binary representation which is then executed by the PHP engine.
Any huge web site running with PHP (Facebook for example) is running some sort of opcode cache system like MMCache.
The problem is that they are not very easy to set up depending on your system.
Depending on how much of your PHP code is actually executed and how long that execution takes they can be a really big win. It certainly isn't going to hurt, but the gain you see will very much depend on where your time is currently spent.
btw mmcache has been rolled into a different project now, I forget the name but Google will tell you.
I use APC on my production servers and it works pretty well out of the box. Compile it and add it to PHP and there isn't much tweaking left to do for it. I check it every once in a while just to review stats but since I use MVC a lot all of the main files (routers, controllers, etc) rarely change on a day-to-day basis so that code stays compiled and runs pretty efficiently.
currently we use apc, free and was just a simple plug and play on our live servers. Provided a huge performance increase for our site, especially as the project size increased. I also have the apc.stat disabled so it doesn't check if the code has been updated, so whenever we need to update the code on the live site we restart apache.
I use APC, and can attest that it can dramatically reduce the CPU and I/O load on an app server if you maintain a high cache-hit rate. It not only saves you from having to compile, it can save you from having to read the php files from disk at all. (i.e. the bytecodes are served directly from main memory, so it's super fast) It lowers the speed to render a single page, and increases the requests per second your server can handle.
If you use RedHat or CentOS, installing APC is super simple:
yum install php-devel httpd-devel php-pear
pecl install apc
echo "extension=apc.so" > /etc/php.d/apc.ini
# if you're using SELinux:
chcon "system_u:object_r:textrel_shlib_t" /usr/lib/php/modules/apc.so
/etc/init.d/httpd restart
You asked about downsides. The only downside is that it requires some memory. The default on APC is 30MB, but it can be adjusted, and the cost of a little bit of memory more than pays for itself with the increased speed and response rate.
BlaM's testing included all the DB calls made by WordPress. When you're making fewer DB calls, you'll see the performance gain of opcode caches be even more dramatic.
I used Zend Accelerator a little back in the day (2004-ish). It certainly gave some significant performance wins on code it could work with, but unfortunately the system I was using was designed to quite often dynamically load code and then eval it, which Zend Accelerator couldn't do much with at the time (and I'd guess still can't).
On the down side, we certainly saw some caching issues (where the code would be changes, but the compiled version sync with the change for one reason or another). I imagine those problems have likely been ironed out by now.
Anyway, I don't have any hard comparison numbers, and certainly didn't write the same system in different environments for comparison, but for the vast majority of systems, PHP isn't going to kill you performance wise.
Have you checked out Phalanger? It compiles PHP to .NET code. Here are some benchmarks which show that it can dramatically improve performance.