mac osx occupied memory increase quickly - macos

I noticed when I run Xcode especially start to run Interface builder.
Mac osx occupied memory increased quickly.
Not only xcode, there are some other apps also cause memory occupy too much after running a while.
Even the memory of my mac is 4GB, some time I have to use tool to free memory.
What is reason and how to avoid this case happen in my developing mac app?
Welcome any comment

I just experienced something similar(but probably not the same) in my Qt application.
I was reading and checksumming lots of files and the free memory kept dropping, though my appliations "real memory" stayed at a steady 50ish MB. However the amount of "Inactive memory" kept climbing.
What was happening was that every file i read was being added to the disk cache. The memory consumed by the disk cache is apperantly marked as "inactive", which should be just as availible as "free" memory according to apple ( http://support.apple.com/kb/HT1342 ) but that didn't stop OSX from starting to swap when "free" hit below 50ish MB.
in C:
#include "fnctl.h"
fcntl(f.handle(),F_GLOBAL_NOCACHE,1);
Seemd to fix that by bypassing disk caching for that file descriptor.
Freeing up inactive memory ( if that is indeed your problem ) can also be done from the commandline using the "purge" command.

Related

How does memory usage in Windows affect performance

I'm running windows 10 with 4GBs of DDR3 1066 on Intel second generation i5 mobile architecture.
I come from a OSX background mostly and memory has always been a concern for me because I prefer to have many tabs open. I noticed on OSX that the memory usage didn't relate that much to the performance of the applications so long as it wasn't fully saturated but easily on my iMac I can run 80% of memory and find no noticeable lag or stuttering. However on Windows I'm finding memory to be the major bottleneck in my system, I understand that upgrading to 8 or 16GBs of memory would be the upgrade path for me. However I would love to understand why my system slows down noticeably when I saturate 80% of the memory unlike OSX that seems to handle it just fine. Is it a bandwidth limitation? I know that Windows NT and Darwin are completely different Kernels and I would love to be educated in exactly how that affects the same usage scenario so differently.
Thank you in advance.

Xcode indicates that nsurlsessiondownloadtask consumes massive amounts of memory

I am using NSUrlSession and NSUrlSessionDownloadTask to download files from a server to my app.
When I am running my app written in Swift from Xcode and looking at the memory consumption gauge the memory consumed increases steadily as the files are downloaded corresponding roughly to the data fetched.
So when downloading 1 GB of files Xcode indicates that my app is using over 1 GB of memory.
This makes absolutely no sense since the downloaded data is saved on disk and not in memory.
Also the app will run without crashing which seems impossible if the reported memory usage is correct.
Have anyone else encountered this issue?

Large stack size in Mac application

I have a cocoa application running on Mac OS 10.8.2. After running for 10 hrs, its memory usage increases considerably. I checked using Instruments tool, but no memory leaks are observed. When I analyze the VM allocations, it shows me that 50% of the memory is consumed by stack pages. It contains around 10K stack pages, which is weird. I have around 17 threads, but they are not created or destroyed during the execution. They are just setup initially.
I am sure that this increased stack size is problem, but I am clueless on how to analyze it further. Instruments tool does not give an idea of who allocated those stack pages.
Please help me. Any hints are much appreciated.

XCode compiling extremely slow inside VMWare

The OSX 10.6.6 is installed inside VMware on Windows 7 host. The overall performance is great, However, the compiling time increased dramatically (1 hour against 2-3 min on pure MacOS). It's modern machine with Core i5 & 4GB RAM.
Here are the XBench results:
http://db.xbench.com/merge.xhtml?doc1=517768&doc2=1&setCookie=true
I think the problem could be in extremely slow 4k write value, but I don't know how to improve this.
Is there any way to increase performance?
UPD1: swap is not used, there is enough memory for all operations
the disk speed is also not related, since my another Macbook shows event worse results, and compiles hundreds times faster.
UPD2: problem solved, see my answer below
Sharing experience and solution.
My Xcode was running fine but when I build a project (even an empty one), it would take up to 10 minutes.
SOLUTION:
Go to Xcode -> Preference -> Source Control: Dissable Source Control
Now projects build and run in a matter of seconds.
In VMWare, you should have a setting where you can dedicate one or two cores entirely to the virtual machine. Assuming you have quad core, maybe give MacOSX 2 or 3 cores? If you have dual-core and you've allocated 1 core to the VM (and the problem still persists), i can't say much then!
It's good that your problem is solved, but I want to share my experience for improving vmware performance. Please do install VMware tools for mac os and they are present in .iso file.
Steps to install VMware tools for MAC OS:
1) Power on your VM.
2) At the right bottom they are some pop-up symbols(These are usually not present in full screen mode). Rightclick the CD/DVD symbol.
3) Click setting. In this window make sure that darwin.iso is selected.
4) Close this window and again right click CD/DVD symbol.
5) Click connect. An icon will appear with name darwin(300).
6) Inside this file tools are present. Install them!
The problem was: VERY SLOW recursive searching of include paths. If non-recursive, everything works smooth.
I also got the same problem, But i want share my personal experience here.
My CPUs RAM capacity is 4 GB, So i allocated 3.5 GB to the VMWare
because of this it was very slow the entire operating system.
So one day i clearly observed the VMWare settings, finally found the
solution. If we allocate the RAM memory more than recommended then
also your operating system hangs. For my System the recommended RAM
memory is 2048MB, after adjusting this now OS is fast.
We can adjust the RAM memory in Devices option, inside Hardware. For
clarification here i am attaching the screen shot.
I had the same problem and I fixed it as follow:
Most boost I got with changing my vmware config file to disable memory
stored in .vmem file. In my .vmx file I added :
mainMem.useNamedFile = "FALSE"
prefvmx.minVmMemPct = "100"
Setting max cores to the guest
When programming with swift and XCode. Remove all comments /* */ not really used.

Increase memory for shared memory

When trying to get shared memory, shmget() often fails because being unable to allocate memory. The physical size of RAM really shouldn't be the problem (4GB is enough, I think).
Rather there's probably anywhere in the systems properties a limit for allocating shared memory set. Does anyone know, where I can find this property?
I'm using Mac OS X Version 10.6
Depends on the OS. PostgreSQL documentation has tips for changing the shared memory limit on various platforms.

Resources