w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to get the memory usage of a process in linux without root permission
I'm not sure exactly what you are really looking for-- do you want to know the amount of memory that a process is currently using? If so, then look at /proc/<pid>/status and examine the VmRSS line. That's the number you want (in this case, RSS means "Resident Set Size" if you're curious). That line should be parse-able in a high-level language like PHP. However, for a lower-level language like C, it should be easier to parse /proc/<pid>/stat which has the same values but each is separated by a space and there are no labels. If you don't have permission to read the file, that means that the server process is running under a different user than you are logged in as. You will need to work with the hosting provider to get that resolved, or figure out how to get the server process

Categories : C++

Profiling Android app for memory usage
Traceview is there for the rescue. See the official documentation http://developer.android.com/tools/debugging/debugging-tracing.html . You can check the memory leaks through it too. DDMS provides a UI for profiling also.

Categories : Android

How to remove file permissions on linux from an external hard drive?
To make the partition accessible under Linux run: sudo chmod -R 777 /media/<drive-name>/ this should make the mac drive accessible for you. Changing ownership would do about the same, but you need not worry about it.

Categories : Linux

Serial Communication gets back wrong answer when something is running in the background (like browsing the hard drive)
Note: serialPort.Write(string) is a non-blocking store into the output buffer. That means the following won't guarantee you've even finished writing your request before you stop listening for a response: serialPort.Write(request); Thread.Sleep(50); _shouldStop = true; You could add: while( serialPort.BytesToWrite > 0 ) Thread.Sleep(1); // force blocking but it's ill advised. One thing I'm wondering. There is only a single serial port here. Why do you want many different threads to work with it when you could manage the entire serial port interaction with a single thread? (Or at worse, 1 thread for input 1 thread for output) To me it makes a lot more sense to store up requests into a queue of some kind and then peel them off one at a time for processing in a single threa

Categories : C#

Java Out of Memory Error(Native memory), the process size limit was hit(32-bit linux)
print the memory size every minute, and found that the VmSize was 2924700 kB before the process died. AFAIK On Linux the OS uses about 1 GB. You need virtual memory for thread stacks, shared libraries, Perm Gen, memory mapped files, and any native resources. If you are getting anywhere near this limit (or if you just have a 64-bit processor) you really should be using a 64-bit OS and JVM. I would use Java 6 update 45, which is end of free support, if not Java 7 update 25.

Categories : Java

How can I lock UI while running the long running process in the main UI Thread in WPF (code in C#)
I would do it this way: Make a "global" (seen for UI thread and background thread) object of one of concurrent types. You can make it as singleton or pass an object to both threads All the long running thread does is reading data from concurrent object and process them. If main thread (or any other) need to do anything in background simply adds it to the concurrent collection. This kind of approach in concurrent programming is called Producer-consumer problem

Categories : C#

How to estimate resource usage while a PHP code is running
I would suggest to use the xdebug profiler. Using it you will know the resource usage even per function exactly and don't have to estimate it. The extension will create so called cachegrind files which can be analyzed by graphical tools like KCachegrind or WinCachgrind Btw if you want to get peak mem usage in php then add this at the last line: echo sprintf("peak memory usage in bytes: %s ", memory_get_peak_usage());

Categories : PHP

Monitoring memory usage of self process
Thread will not work, since C and C++ mandate that returning from the main function kills all running threads (courtesy Do child threads exit when the parent thread terminates). You will need to make it another process, perhaps a script that starts the process which then manages your application.

Categories : C++

Max memory usage of a chrome process (tab) & how do I increase it?
By default v8 has a memory limit of 512MB on 32-bit systems, and 1.4GB on 64-bit systems. The limit can be raised by setting --max_old_space_size to a maximum of 1024 (1 GB) on 32-bit and 4096 (4GB) on 64-bit. You should be able to set this parameter when launching Chrome from a shell in Linux, or as an argument to the shortcut path in Windows.

Categories : Http

Limiting the memory usage of a program in Linux
The fact that you’re using Wine makes no difference in this particular context, which leaves requirements 1 and 2. Requirement 2 – I do not want the process to crash once it exceeds the limit. I want it to use HDD page swap. – is known as limiting the resident set size or rss of the process, and it’s actually rather nontrivial to do on Linux, as is demonstrated by a question asked in 2010. You’ll need to set up Linux control groups (cgroups). Fortunately, Justin L.’s answer gives a brief rundown on how to do so. Note that instead of jlebar, you should use your own Unix user name, and instead of your/program, you should use wine /path/to/Windows/program.exe. Using cgroups will also satisfy your other requirements – you can start as many instances of the program a

Categories : Linux

how can i get the max memory usage of a child process after its execution accurately?
Once the process terminates, even though the process entry still exists in the kernel, all of the resources for the process are released by the kernel. So, I would not expect to be able to read the memory size of the process from /proc. In addition, there's no "maximum memory used" statistic for the process. The only ways I can think to determine the maximum amount of memory for a process are the following: Periodically sample the process state while it's executing and grab the current memory usage, Use strace to capture all of the system calls made by the process and process this to determine just how much memory the process used, or Use a shared library to intercept the memory-allocation system calls as they are made by the process, capture the details, and find a way to report I

Categories : Linux

Linux free shows high memory usage but top does not
Don't look at the "Mem" line, look at the one below it. The Linux kernel consumes as much memory as it can to provide the I/O cache (and other non-critical buffers, but the cache is going to be most of this usage). This memory is relinquished to processes when they request it. The "-/+ buffers/cache" line is showing you the adjusted values after the I/O cache is accounted for, that is, the amount of memory used by processes and the amount available to processes (in this case, 578MB used and 7411MB free). The difference of used memory between the "Mem" and "-/+ buffers/cache" line shows you how much is in use by the kernel for the purposes of caching: 7734MB - 578MB = 7156MB in the I/O cache. If processes need this memory, the kernel will simply shrink the size of the I/O cache.

Categories : Linux

How to update UI before (and after) long running UI process in WPF?
You cannot manipulate UI controls in a background thread. If you are using the main UI thread to create your TabItems, then you also cannot have a 'Busy' or 'Loading' indicator... this will only work if you are using a alternative thread for your long running process. This is because your 'Busy' indicator will only become updated once the long running process has completed if it runs on the same UI thread.

Categories : C#

Implement a long-running process in a web app
Can we use jquery ajax for this success: function(xhr_data) { console.log(xhr_data); if (xhr_data.status == 'pending') { if (cnt < 6) { cnt++; setTimeout(function() { ajax_request(); }, 15000); // wait 15 seconds than call ajax request again } } else { success(xhr_data); } }

Categories : Java

Is it possible to determine how long a process has been running
Process.GetProcesses will retrieve a list of running processes. Each Process has a StartTime property that Gets the time that the associated process was started. Simply subtract that from DateTime.Now to get how long the process has been running. static void Main(string[] args) { var procs = Process.GetProcesses(); foreach (var proc in procs) { TimeSpan runtime; try { runtime = DateTime.Now - proc.StartTime; } catch (Win32Exception ex) { // Ignore processes that give "access denied" error. if (ex.NativeErrorCode == 5) continue; throw; } Console.WriteLine("{0} {1}", proc, runtime); } Console.ReadLine(); }

Categories : C#

Linux kill my process for out of memory, how to see how much I use?
First you need to identify what system process is killed by OS. Then I'd enable .core dumping and analyse it. Please check for ulimit -c command and appropriate configuration to get this. Of course you need to enable debug symbols for your program to get most of it. In case you cannot dump (have no sufficient space or any other limitation), consider remote debug with debug version of process on client side. I think you should be able to use something like 'remote GDB debugging' for this. Most probably your process fails on some memory allocation and this has great chance to explain where you 'eat' memory, who is guilty and probably what to do with this. Hope this will help.

Categories : Javascript

What could cause a sudden ClassNotFoundException in a long running process?
The stack trace tells us that it is about processing annotations and not connected with loading the class for executing code. It seems that the annotation processor tries to resolve the value of an annotation member through the ClassLoader of the annotated element. In other words you have an annotation with a value of class type like @Foo(xyz=ABC.class) and a class or member annotated with this construct but the class ABC is not reachable through the ClassLoader of the annotated element at runtime. This does not conflict with the fact that this class has already been loaded through another ClassLoader.

Categories : Java

Weird JVM crash on long running process - Possible JVM bug
Your application is receiving a signal as apparent from the stack trace: JVM_handle_bsd_signal I don't know which signal it is, but you could try to install signal handlers to find out: http://www.oracle.com/technetwork/java/javase/signals-139944.html#gbzbl Some common things that come to mind are: does the app set up some ulimits ? does anything else crash, suggesting hardware errors? have you tried using another jvm release - a patch or two away might be a different behavior

Categories : Java

Showing MessageBox in long running process
Maybe you can use a delegate? For the method you showed, you can create a delegate like this: public delegate bool ShowMessageBoxDelegate(string text); Then let's say you have a property using the delegate as the type: public ShowMessageBoxDelegate ShowMessageBoxDelegateProperty { get; set; } Now if your ShowMessageBox method matches the signature of this delegate... public bool ShowMessageBox(string text) { var result = MessageBox.Show(text, "", MessageBoxButton.YesNo); if (result.Equals(MessageBoxResult.Yes)) { return true; } return false; } ... then you could set it as the value of the ShowMessageBoxDelegateProperty property: ShowMessageBoxDelegateProperty = ShowMessageBox; Note the missing parenthesis. A delegate can also be multicast, which si

Categories : C#

Why my java process used memory(Linux RES) keep increasing?
I suggest you look at pmap for the process. This will give a you a breakdown of native memory usage. Memory which you don't have so much control over are The total stack space used by threads. The size of memory mapped files The size of shared libraries. Native library memory usage. e.g Socket buffers (if you have enough sockets) Some combination of these is using the difference.

Categories : Java

How to monitor a process in Linux CPU, Memory and time
I typically throw together a simple script for this type of work. Take a look at the kernel documentation for the proc filesystem (Google 'linux proc.txt'). The first line of /proc/stat (Section 1.8 in proc.txt) will give you cumulative cpu usage stats (i.e. user, nice, system, idle, ...). For each process, the file /proc/$PID/stat (Table 1-4 in proc.txt) will provide you with both process-specific cpu usage stats and memory usage stats (see rss). If you google a bit you'll find plenty of detailed info on these files, and pointers to libraries / apps / code snippets that can help you obtain / derive the values you need. With that in mind, I'll focus on the high-level strategy. For CPU stats, use your favorite scripting language to create an executable that takes a set of process ids f

Categories : Linux

Linux ptrace memory reading & process management
Found the solution to be that when using ptrace() you must call in an order: ptrace(PTRACE_ATTACH, pid, NULL, NULL) ptrace(PTRACE_PEEKDATA, pid, addr, NULL) ptrace(PTRACE_DETACH, pid, NULL, NULL) So the simple answer: You need to attach and detach before and after reading the memory. It may also be useful to know that between the attach and detach commands, the process will sleep, meaning this method isn't so good for my purpose, but may be useful to others :) Thanks to @PeterL. for your help.

Categories : Linux

Avoid timeout on long running process of report generation
The cleanest way to handle such issue is to have an asyncronous communication with your client. The first request /myApp/report?name=...&paramters... triggers jasper report to refresh the report and returns a ticket id Then, the client have to call another url to retrieve the report (for instance every 5 seconds) /myApp/reportDownload?ticketId=xxxxx If the jasper thread is over and the report ready, you send back the report, otherwise tell the client to retry in 5 seconds until it gets the report. The way to implement it depends on the technlogies you are using in for the front and backends, but you'll find dozen of tutorials on the internet. The worst way to fix it is to increase the timeout in the connector configuration (http://tomcat.apache.org/tomcat-7.0-doc/config/http.html)

Categories : Spring

How many open files for each process running for a specific user in Linux
This command will tell you how many files Apache has opened: ps -A x |grep apache | awk '{print $1}' | xargs -I '{}' ls /proc/{}/fd | wc -l You may have to run it as root in order to access the process fd directory. This sounds like you've got a web application which isn't closing its file descriptors. I would focus my efforts on that area.

Categories : Linux

Tomcat process killed by Linux kernel after running out of swap space; don't get any JVM OutOfMemory error
You probably have other processes on the same computer that also use memory. It looks like your java process reaches around 5.3GB before the machine is desperately out of RAM and swap. (Other processes are then probably using 12GB-5.3GB = 6.7GB) So your linux kernel sacrifices your java process to keep other processes running. The java memory limit is never reached so you're not getting an OutOfMemoryException. Consider all the processes you need running on the entire machine, and adjust your Xmx setting accordingly (enough to leave room for all the other processes). Perhaps 5gb? In any case, counting of OutOfMemoryExceptions being delivered is a pretty bad code smell. If I recall correctly, getting even a single OutOfMemoryException can leave the JVM in an "all-bets-are-off" state and

Categories : Java

Clock_gettime showing high usage during profiling of code
It's all relative to whatever else your program is doing, and keep in mind that if you're doing any I/O, the actual CPU time your program uses may be small, and gprof doesn't see anything else. So if some calls to timing routines get stuck in there, and they are called often enough, sure they can show a high percent. Why doesn't gprof show where they're being called from? For routines compiled with -pg, it tries to figure out who the caller is when any routine is entered. It tries, but that doesn't mean it succeeds. Anyway, that's gprof.

Categories : Misc

how to shrink KVM hard drive image
Images can be sparsed, and your cp might not respect that for various reasons. I would: check the real file usage (du -sh vm.img or qemu-img info vm.img) use qemu-img convert -S to recreate a sparse image convert to qcow2 to have growing and versatile image instead

Categories : Misc

Methods for tracking changes to hard drive
For realtime tracking when file or directory changes you can use inotify on Linux or FileSystemWatcher on Windows. Combine with rsync to get delta.

Categories : Svn

Is there a way to read directly from the hard drive to the GPU
The GPU is not directly connected to the system RAM. There's a bus inbetween, in current generation computers a PCI-Express bus. ATA storage has a controller inbetween. There is no direct connection between memories. BUT there is DMA, which allows certain periphials to directly access the system memory through DMA channels. DMA on PCI-Express also works between periphials. Theoretically a GPU could do DMA to the ATA controller. Practically this is of little use! Why? Because of filesystems. Even if there was some kind of driver support to let the GPU access a storage periphial directly, it'd still have to do all the filesystem business, which doesn't parallelize to the degree as GPUs are designed for. Alas regarding your question: In my OpenGL program I read from the header file t

Categories : Opengl

Adding a new hard drive to xampp
If you want to sort of "span" the drive, Windows has this handy feature (similar to linux's symlinking) called mklink which you can create a folder in the current directory that is just a symbolic link to the drive. Quick and easy way to span it. I am not sure of any downsides to do doing this, other than if the drive letter changes (if external drive). That way you should not have to add or change any of your paths in the config etc. Not sure if that is what you were looking for, but hopefully it helps. Also, did you try your 3rd config you pasted? Did it not work? From what I can see, as long as permissions are fine it should work that way.

Categories : PHP

Profiling ASP.net applications over the long term?
We use Microsoft's Application Performance Monitoring for this. It captures page load times, DB call times, API call times, etc. When a page load is unexpectedly slow, it also alerts us and provides the stack trace along with the timings of various calls that impacted the load time. It's somewhat rudimentary but it does the trick and allowed us to verify that we didn't have any variations that were not performing as expected. Advance warning: the UI only works in IE. http://technet.microsoft.com/en-us/library/hh457578.aspx

Categories : Asp Net

What slows down Java if CPU usage low, hdd usage low, memory usage low?
You can test what is the bottle neck by taking different parts out of the equation. To take out the CPU, just read the files and don't do anything else. To take out the disk, keep reading the same file again and again, assuming it fits in your file cache. Compare this to the time for everything.

Categories : Java

Accessing a file on the server's hard drive
You cannot reach the file that is "above" the wwwroot folder by design. The way to do this is to a) copy the file there, b) setup a symbolic link (if on linux) or c) preferably, move / setup another web root folder. Alternatively, write a server script to dump the file contents.

Categories : Javascript

Unmount my external hard drive in bash
Searching for "Unmount Hard Drive Terminal" yields http://ubuntuforums.org/showthread.php?t=842698 as the first result. >.> russlar provides a solution: open terminal, and run df -h. this will tell you all the hard drives mounted. then, run sudo umount /dev/something, where somethign is the name of the hard drive that you want to unmount. Nothing wrong with asking, but when a solution is on the first Google result, it's a little... odd.

Categories : Misc

How to identify system hard drive using Win32_DiskDrive
The documentation you linked has the answer: string SerialNumber; uint32 Signature; Your management object will have those properties in it. If you're getting null for those values then the problem is that you're using a version of Windows that doesn't support them. SerialNumber ... Windows Server 2003 and Windows XP: This property is not available. In which case you have to use the Signature property, but this requires XP SP3 I believe.

Categories : C#

Save Work Done In MS Word To A Database Not On A Hard Drive
The method you are using is extremely inefficient and I wouldn't recommend the process, but the reason that you code is failing is your length.... when you are saving your MemoryStream you are setting the length int len = Application.ActiveDocument.Content.StoryLength; but when you try to retrieve it, you are setting it int len = int.MaxValue; which would be far past the end of the data stream.

Categories : C#

Remove files from a NetBeans project but not the hard drive
Solution working with Netbeans 7.3.1: right click on your project in the "Projects" window, click on "Properties", click on "Ignored folders" in the left panel called "Categories", click on "Add folder" and select the folders you want to ignore.

Categories : Misc

Android 4.3 On-screen GPU profiling - long gfx waiting time
"Waiting for commands to complete" indicates that there are dependencies on rendered frames. For example, the app might be using glReadPixels to read from the rendered frame. This means that after the frame has been sent to the GPU for rendering, the app is blocked until rendering that frame finishes (whereas normally it would be able to continue right away). Android tries to let the app queue up as many rendering commands as possible, so suddenly introducing a wait might actually mean the app has to wait for several previously queued frames to be drawn before the frame it's waiting for is rendered. glReadPixels isn't the only command that causes this kind of dependency. If an app wants to write to a texture that's currently being used, it has to wait until all the frames that depend on t

Categories : Android

Profiling shows long execution time in PropertiesEnhancer
Reflection is not a cheap operation. The method you mention makes it even worse: trying to get a method via reflection first, possible catching an exception and trying to get a field then. And the method does not do any attempt of caching results. If this is called very often it’s no surprise that it is eating a lot of CPU time. Whether it is possible to work-around this without changing the library, I don’t know. The only context I have is that single method reference from you. That’s not enough.

Categories : Java

Closing socket after subprocess.Popen leaves socket in TIME_WAIT as long as child process is still running
Closing socket after subprocess.Popen leaves socket in TIME_WAIT as long as child process is still running No it doesn't. It leaves it in TIME_WAIT for a fixed amount of time, 2 or 4 minutes. After the close it has nothing to do with the child process at all.

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.