w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
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 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++

Purpose of Curly Brace Usage of C Code found in Linux (include/linux/list.h)?
This is a GNU language extension known as a statement expression; it's not standard C.

Categories : C

Memcached slow gets, high CPU usage
Well, I've found the problem! To get an idea of the requests per second I used the memcache.php file that's available out there. It told me that there were 350 requests per second. The thing is that there has been quite an increase of use in the past few days, and the requests/second is really just an average over the entire uptime. Calculated by (hits+missed)/uptime. Now after restarting memcached this average returns more correct values and there are actually 4000 requests per second. tl;dr: Wrong stats in first post. Correct stats are: 4000 requests/second. I suppose my hardware simply can't cope with that.

Categories : PHP

TCP/UDP high-performance server under linux
Your basic approach is right. Start by studying the infamous C10K problem and how it was overcome. Once you understand the major bottlenecks in various implementations, you need to consider the following as part your design process : Minimise thread creation/deletion cycles. Always choose an "event-based" model over a blocking model. Basically the one-thread-per-request model is preferred for its simplicity of implementation. But it does NOT scale well with the number of concurrent requests. When designing systems required to support more than a few 1000 concurrent requests, one prefers the use of sockets over threads. The optimum number of "worker-threads" to instantiate depends upon : Load (number of concurrent requests) System (CPU, RAM) Since this is a very popular probl

Categories : Linux

In Java What is the exit value of a process which is killed in the background through Linux shell using process id
This is not a Java specific question. The return code will be the same for all Unix systems here (at least I have never seen a Unix system not behaving this way): 128 + the number of the signal which caused the process to terminate. No idea for Windows... Therefore, 130 in your case. In C, you'd check (after a call to waitpid() for instance) whether a process has been terminated by a signal using WIFSIGNALED(status).

Categories : Java

Getting the list of child process, called by a parent process in Linux
The f option of the ps command will help. Try: ps afx This will show all processes and will visualize parent -> child dependencies in the console.

Categories : Linux

Linux's top CPU usage - always the same value
This is because top, vmstat, iostat all in their first run collect data since the last reboot time of the system. And the successive iterations run on the sampling period that you specify. So, in the first run of top, you will see the %idle time because from the time of reboot to the time of running top, it was that much % idle. But in next iterations, since it is busy it doesn't show any %idle. You get try this: top -b -n 5 -d.2 | grep "Cpu" | tail -n 1 | awk '{ print($2)}' or slightly shorter top -b -n 5 -d.2 | grep "Cpu" | awk 'NR==3{ print($2)}' It should print something like: 48.8%us,

Categories : Linux

About the usage of linux command "xargs"
xargs puts the words coming from the standard input to the end of the argument list of the given command. The first form therefore creates cp /tmp/ ./useful/love.txt ./useful/loveyou.txt Which does not work, because there are more than 2 arguments and the last one is not a directory. The -i option tells xargs to process one file at a time, though, replacing {} with its name, so it is equivalent to cp ./useful/love.txt /tmp/ cp ./useful/loveyou.txt /tmp/ Which clearly works well.

Categories : Linux

How to get the Parent Process ID by giving a Process ID in Linux using C/C++?
I think you can use get_proc_stats function to do this. But you need to install the libproc-dev library. Here is an example : proc_t p_info; get_proc_stats(pid_num, &p_info); int parent_pid = p_info.ppid;

Categories : C++

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

File-copy using Java NIO is slow on Linux
Java will be accessing the SMB share via a regular file system mount. It is possible that Nemo is accessing the SMB share via a different mechanism that is faster / better tuned. Either way, if file transfer speed is critical, you will most likely get best results using an external application. (Exactly which one will be OS specific ... and beyond the scope of StackOverflow.) I had a brief look at how Files.copy is implemented. It appears that the actual file copying is implemented by a native code method (sun.nio.fs.UnixFileCopy.transfer(...)). Based on that, I don't think that a utility that copied a large file (via a regular file system mount) should go significantly faster than Files.copy(...). It would need to access it a different way to achieve a significant speedup.

Categories : Java

OpenCL/GL Interop slow on nvidia/win but fast on linux?
I'm gonna make the assumption that since you are using OpenGL, you display something on the screen after the OCL computation. So based on that assumption, my first thought would be to check in the NVIDIA control panel if the VSync is enable and if yes to disable it and retest. As far as I recall, the default options regarding vsync are different for AMD and NVIDIA; which would explain the difference between the two GPUs. Just in case, here is a post that explain how vsync can slow down the rendering.

Categories : Performance

Linux Process Scheduler
From the man page of sched_setscheduler(), For processes scheduled under the SCHED_FIFO policy, the following rules apply : A SCHED_FIFO process that has been preempted by another process of higher priority will stay at the head of the list for its priority and will resume execution as soon as all processes of higher priority are blocked again. When a SCHED_FIFO process becomes runnable, it will be inserted at the end of the list for its priority. A call to sched_setscheduler() or sched_setparam() will put the SCHED_FIFO process identified by pid at the start of the list if it was runnable. As a consequence, it may preempt the currently running process if it has the same priority. (POSIX.1-2001 specifies that the process should go to the end of the list.) A process ca

Categories : C

Terminate all child process in LInux
You could use process groups setpgid(2) and sessions setsid(2), but I don't qualify what you do as a sandbox (in particular because if one of the processes is setuid or change its process group or session itself, you'll lose it; read execve(2) carefully and several times!). Notice that kill(2) with a negative pid kills an entire process group. Read a good book like Advanced Linux Programming. Consider also using chroot(2). And explain what and why you really want to do. sandboxing is harder that what you think. See also capabilities(7), credentials(7) and SElinux.

Categories : Linux

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

Setting CPU affinity to a process - C - Linux
OK. This is the stupidest thing that one can ever do! CPU_SET(pid, &mask); CPU_SET(coreid, &mask); changing the pid to the coreid will do it. The other mistake was here: result = sched_setaffinity(pid, sizeof(mask), &mask);

Categories : C

How to get files modified by certain process in Linux
If the process is not already running, you can use strace to print system calls strace -o logfile <program> After this, write a script which will look for open() and write() system calls, and able to print the lists of files which are written too. If the process is already running, you will have to use the combination of several things lsof -p or /proc/<processid>/fd/* last modified time stamp of the files found in above output of strace -p <processid> to look for write() and open() Hope that helps

Categories : Linux

Linux Threads and process - CPU affinity
when process goes in to sleep and when it wake up ,it is not necessary that it will schedule on same cpu.if u have multiprocessor environment then according to scheduler policy it will schedule on any cpu.When process goes to sleep there are different reason ,it goes to sleep beacause it is waiting for io,any resource.When event will occurs it goes from waiting state to ready state.At that time which cpu will be free scheduler will schedule that process on free cpu.It is not necessary it will schedule on same cpu. for extra information about scheduler open source code of scheduler in linux release tree path.

Categories : Linux

cross-process locking in linux
You can use file locking facilities that Linux provides. You haven't specified the language, however you might find this capability pretty much everywhere in some form or another. Here is a simple idea how to do that in a C program. When the program starts you can take an exclusive non-blocking lock on the whole file using fcntl system call. When another instance of the applications is attempted to be started, it will get an error trying to lock the file, which will mean the application is already running. Here is a small example how to take the full file lock using fcntl (this function provides facilities for putting byte range locks, but when length is 0, the full file is locked). struct flock lock_struct; memset(&lock_struct, 0, sizeof(lock_struct)); lock_struct.l_type

Categories : Linux

How to really free hugepages in Linux for use by a new process?
You can very likely get Java to re use the objects still in memory, However, running the following will remove that and everything else also stored and not being used echo 3 | sudo tee /proc/sys/vm/drop_caches But you dont really need to - although its "taken" its not really. As soon as anything actually needs the ram linux will give it back for more info check out http://www.linuxatemyram.com/ You dont actually need to do anything its normal. The only memory you have to worry about really is the memory when your application is running

Categories : Java

using fwrite as an atomic process on Linux
First write the file to a temporary path on the same filesystem, like /etc/routing_table.tmp. Then just rename the copy on top of original file. Renames are guaranteed atomic. So, the sequence of calls would be, fopen, fwrite, fclose, rename.

Categories : C

Linux zombie process Xsession
Here... I've been using a modified version of this for a while. http://www.mariusv.com/automatic-zombie-processes-killing-shell-script/ Cron it to run every x minutes.

Categories : Linux

Popen new process group on linux
bash does not handle signals while waiting for your foreground child process to complete. This is why sending it SIGINT does not do anything. This behaviour has nothing to do with process groups. There are a couple of options to let your child process receive your SIGINT: When spawning a new process with Shell=True try prepending exec to the front of your command line, so that bash gets replaced with your child process. When spawning a new process with Shell=True append the command line with & wait %-. This will cause bash to react to signals while waiting for your child process to complete. But it won't forward the signal to your child process. Use Shell=False and specify full paths to your child executables.

Categories : Python

Exec(Linux). How it functions internally? Linux executable attributes(rlimit)
The RLIMIT_CORE is used to place a limit on the amount of info that coredump is allowed to produce, before it is aborted. Once this limit is hit, no more info is logged and the message Aborting Core is logged to the console. From the man page of core : A process can set its soft RLIMIT_CORE resource limit to place an upper limit on the size of the core dump file that will be produced if it receives a "core dump" signal. Use setrlimit() to configure RLIMIT_CORE to a larger value to obtain complete coredumps. The most common format of executables/shared-objects is ELF. On Linux, the dynamic loading and linking of these shared-objects is performed by ld.so ld.so is loaded in the address space of a newly created process (by exec in this case) and executed first. This is possible as

Categories : Android

Linux users', specifically Apache, permissions settings, [Linux noob :]
usually any daemon will need to access a number of ressources. it is therefore good practice to run each daemon under a special user:group, rather than nobody:nogroup. traditionally (e.g. on Debian systems) apache runs as www-data:www-data. finally, user permissions take precedence over group permissions (which in turn take precedence over other permissions). this means that a directory where the user does not have write perms but the user's group can write is effectively r/o for that user (but not for other members of the group)

Categories : Linux

What's a good way to set up Closure Compiler on Linux? Or, where should Java .jar's live on a Linux?
If you using the java command directly, then you'll have to provide a path to the jar in question. It's probably easier to place the jar in one place and create a shell script that handles the invocation and jar path.

Categories : Java

How to turn a Linux application in C/C++ into a Desktop Enviroment for a Linux distro?
You either want to create a boot loader, or you want to replace the 'shell'. This would be governed by per-user or global xinit and Xsession files.

Categories : C

Write C++ on Windows but use Linux System calls through a Linux emulator
You've already tagged your question with Cygwin. That seems like the best solution for what you want. Cygwin is basically a collection of programs which emulate a GNU/LInux environment through the use of a DLL (cygwin1.dll) which acts as a Linux API layer providing substantial Linux API functionality. Here's the link to the documentation for its API Edit: Most of the Cygwin source code that I've looked at is written in C++ and makes system calls using MS Windows API to do provide the *nix emulation. The source is well written and very readable (even to to a non-C++ programmer such as myself). I think using Cygwin would be a good transition from programming on Windows to a GNU/Linux environment.

Categories : C++

linux pass text into readline of a given process
The first option: Python provides subprocess package to perform this task. You need to use pipes provided with subprocess package. Reference here. The second option: You can use multiprocessing package for better control and more options; pipes still available. Additionally you can use Queue, Array and Lock to facilitate interprocess communication. Reference here.

Categories : Linux

how can I use linux command sed to process Little-endian UTF-16 file
if you can cat the file, then you may use sed. no harm in trying before you ask the question. if the check-free-ip.to.rdpzhitong.rdp file has any text, you may want to do this: address=$(sed 1q check-free-ip.to.rdpzhitong.rdp) sed -i "s/address:s:.*/address:s:$address/" rdpzhitong.rdp also, a little advice. try without the -i switch, until you know it's working.

Categories : Shell

What kind of privilege do we need to trace a process in linux
You can always hash the password because issuing the system call, I think. And I think you require a given amount of privilege to hook the login manager's API calls, so there shouldn't be any problems.

Categories : Linux

Linux boot process -- iniramfs & root ()
With initrd there are two options: Using pivot_root to rotate the final filesystem into position, or Emptying the root and mounting the final filesystem over it. More info can be found here.

Categories : Linux

how to find out why the process is sleeping/blocked in linux
If your process is blocked on a system call, you can use strace to find out what it is. Note that the strace binary may not be installed on your android system, but there is a version of it in recent versions of busybox. Also you may need root access, so you'll want to jailbreak your android device. Here's a contrived example. $ mkfifo /tmp/foo $ cat /tmp/foo & # blocks $ ps # note pid of the blocked "cat" process; in my case it's 29739 $ sudo strace -p 29739 # attach to the process The output of strace in this case is: Process 29739 attached - interrupt to quit open("/tmp/foo", O_RDONLY^C <unfinished ...> strace will then hang along with your process; hit ctrl-c to break. Here's another example: $ nc -l 8888 & [2] 31087 $ sudo strace -p 3108

Categories : Android

Sample Multi Process applications in Linux
Any shell pipeline: grep whatever myfile | head -100 Uses two processes (grep and head) to show you the first hundred lines containing whatever in myfile. This sort of thing is all over the place in Linux, or any *nix-like system. More specifically, it is a key feature to implement the Unix Philosophy, and is central to any shell, like Bash, Korn Shell, Z Shell, Dash, C Shell, etc. Linux is made of multiprocessing. If you still aren't convinced, look at sshd which accepts incoming logins from other machines by spawning a process for each one.

Categories : Misc

C++ process management: WinAPI "SetProcessShutdownParameters " in Linux?
System shutdown in the Unix world works a bit differently. When the system is being shut down, at first the shutdown scripts are invoked, which handle any complex or time consuming tasks, and when the scripts have run, all remaining processes are then first sent a SIGTERM signal (which kills any process that doesn't have an explicit handler), and, a few seconds later, a SIGKILL signal (which kills the process and cannot be handled). The order in which the last part happens is undefined. In general programs should be written so they can be shutdown by simply sending SIGTERM. I'm guessing that you want the parent stopped before the child because the parent would simply restart the child. The proper way to avoid that is to collect the child's exit status (which you are responsible for any

Categories : C++

Whether Linux Kernel can be thought of as a single process
Linux kernel can't be considered as a process, because this is one of its responsibilities to manage processes. You can consider kernel as a big interrupt handler. After the kernel grants processor to the thread, the only way to get control back are interrupts (or system calls, which are also interrupts). When interrupt occurs, kernel immediately gets control, and appropriately handles interrupt. At this point various parts of kernel could be called. Kernel is multi-threaded as it can handle various interrupts on different processors simultaneously. On the other hand, there are kernel-threads, which are managed in the same way as user threads (there is no difference between kernel and user threads for scheduler).

Categories : Linux

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

How to know the reason why the process was killed by system(linux)
The exact log file varies dependingon distribution and configuration, but if you do ls -ldrat /var/log/* it will show the most recently edited logfiles at the bottom. The files messages,dmesg and daemon are all likely sources of information. Possible reasons are: memory exception (i.e. segfault) process limits breach (to many File descriptors or processes being opened) - check /etc/security/limits.conf and surrounding files SElinux (if enabled) - that should have been logged to messages.

Categories : Linux

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



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