Programming :: Explorations In Memory Allocation In ANSI C?

Feb 8, 2011

I'm performing some explorations in terms of memory allocations in ANSI C, using the following compiler:

gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)

and I started to try to make the compiler complain for a huge data structure, so I coded this:

[code]....

I mean, I can always read the man entry for gcc but I rather ask because I can then have interaction...

View 11 Replies


ADVERTISEMENT

Programming :: Process Memory Allocation

Apr 30, 2011

I have been assigned a school project on detecting memory leaks in linux processes. I am reading.. but have found it hard and inefficient to go through the very vast documentation not knowing what to really look for. Could you please give me some guidelines on this subject?

View 4 Replies View Related

Programming :: Memory Allocation For Struct In C++?

Mar 30, 2010

How do we allocate memory of struct? what i did was

Code:

int main()
struct amp
{

[code].....

cout <<"The size of 'struct' is"<< sizeof(struct amp)<<"and it is located at"<<struct amp*s = malloc(sizeof(struct amp))<<endl;
it gives me an error---
In funtion 'int main()':
error: expected primary-expression before 'struct'
error: expected ';' before 'struct'

View 9 Replies View Related

Programming :: The Continuous Memory Allocation Is Larger 128kB For DMA Process?

Jun 3, 2010

I want to allocate the continuous memory larger 128k for DMA process. But i can't used kmalloc() function for allocate the memory larger 128KB. allocate the continuous memory larger 128k for DMA process.

View 1 Replies View Related

Programming :: Write Script To Look For The Presence Of Memory Allocation Calls Without Corresponding?

May 14, 2011

I need to write script to look for the presence of memory allocation calls without corresponding calls to free the memory

View 5 Replies View Related

General :: Application Virtual Address Space Memory Allocation - Memory Does Not Get Free

Apr 20, 2010

I am using malloc and frees a lot in my program. It shows its allocated but when i remove it doesnt show as the memory is removed(I am using the top command to view VIRT memory usage). If this continously grows what would happen to my program (Will it go out of memory?)

View 4 Replies View Related

General :: Memory Allocation - How To Disable Overcommit

Oct 17, 2010

I've been looking into memory overcommitting in Linux using /proc/sys/vm/overcommit_memory, and I've read a few articles which don't say the same thing. This doc, under the heading "Going in the wrong direction", goes on to say, "values 1: do overcommit, and 0 (default): don't", but then in the next few lines, it mentions, amongst similar things, that this isn't actually true and that 0 means "guess about how much overcommitment is reasonable". That means that memory overcommit isn't disabled using value 0, right?

It also says that 1 indicates "never refuse any malloc()", with 2 meaning "be precise about the overcommit - never commit a virtual address space larger than swap space plus a fraction overcommit_ratio of the physical memory." The Red Hat magazine, on the other hand states, "if the value is 0, then the kernel checks to determine if there is enough memory free to grant a memory request to a malloc call from an application. If there is enough memory, then the request is granted. Otherwise, it is denied and an error code is returned to the application."

This sounds exactly like disabling overcommit. "If the value is set to 1, then the kernel grants allocations above the amount of physical RAM and swap in the system as defined by the overcommit_ratio value.... If the setting in this file is 2, the kernel allows all memory allocations, regardless of the current memory allocation state." In terms of values 1 and 2, that is the opposite of what the previous doc said, right? What is actually correct, and if it is possible to 'disable' overcommit?

View 1 Replies View Related

Fedora Servers :: Virtual Machine Manager Won't Allow Memory Allocation Over 1024

Jan 26, 2010

I'm running Fedora 11 (2.6.30.10-105.2.4.fc11.i686.PAE) 8 GB memory on a AMD Phenom(tm) II X4 965 Processor, 4 core server I just built.The problem I have run into is any virtual machine that has >1024 MB memory assigned to it will not boot. As along as it has 1024 MB or less it boots fine.The symptom you see is a very quick message "Booting from hard disk" the screen then goes blank, you can't login through SSH, and can't ping the network address so I know it's not some crazy video problem hiding the boot process.The attachment are messages from a failed boot attempt.

View 4 Replies View Related

Ubuntu :: Slow Gaming Experience - Increase Graphics Memory Allocation?

Jun 9, 2011

When I play Bejewelled Blitz on Mozilla firefox or Google Chrome,, it is so painfully slow that it is frustrating, I have all the latest updates from Ubuntu installed including the Adobe flashplayer. Is there some way I can increase the graphics memory allocation?

View 5 Replies View Related

Programming :: Book To Learn Programming In C ANSI?

Jul 11, 2011

What book you recommend to learn programming in C ANSI ?

View 1 Replies View Related

Programming :: ANSI C Code Seg-faults When Unsigned Int Variable Is Used?

Feb 20, 2011

I'm writing a tridiagonal solver for sparse linear systems and I coded this decreasing loop:

PHP Code:

xx[NN - 1] = gamma[NN - 1]*BB[NN - 1];
ii = NN - 2;
/* Compute the x values: */
while (ii >= 0) {
xx[ii] = gamma[ii]*(BB[ii] + xx[ii + 1]);
ii = ii - 1;


now... if ii is declared as an unsigned integer, the code gives me a segmentation fault, but if I declare it as an int, it doesn't. Using DDD I noticed that, as an unsigned int variable, when I finally decrease it, it underflows and blows up to a huge value, ergo giving me an unaccesible direction for xx in the following iteration! I taugh me not to use unsigned int variables for dereasing loops! XD

View 14 Replies View Related

Fedora :: User Memory Allocation - Set A Maximum Limit On The Amount Of Ram A User Can Utilize?

Jul 24, 2009

I have a few multi-user servers in an academic laboratory. I am having a problem with some users maxing out the available RAM, causing such sever slowdowns the machine essentially crashes. My servers are Dell Power Edge's running Ubuntu 8.10 Server Edition (Not my choice). I would like to set a maximum limit on the amount of ram a user can utilize. This morning I experimented with setting limits via /etc/security/limits.conf and using ulimit. Neither of them prevented my test program, a simple infinite loop of mallocs, from crashing the server.

View 7 Replies View Related

Programming :: 32-bit Executable Getting St9bad_alloc @ 3GB Mem Allocation

Jan 13, 2010

I'm maintaining a c++ application running on a 64-bit RHEL5 server w/32GB ram, but compiled to be a 32-bit executable with g++. The application handles large amounts of data, and has lately been throwing a st9bad_alloc exception. "top" shows the application as dieing right around when VIRT=~3GB, SWAP=~1.5GB and RES=~1.5GB. In the core dump I can see that it's consistently failing to push_back() a piece of data onto a std::vector (which already has hundreds of thousands of objects in it).

I know 4GB is the maximum address space for 32-bit applications. I've learned from this lwn article that a 32-bit kernel reserves 1GB of address space, leaving 3GB for user space. However I'm not running a 32-bit kernel, so that really doesn't answer anything.I wrote a dummy app which called malloc() over and over in a for loop, and it is able to allocate right up to the 4GB before it fails. I don't understand why this one seems to be able to allocate more.

The only difference between the two apps (besides malloc vs std::vector:ush_back), is that the 3GB crashing application attaches to 512mb of shared memory.Anyone have any ideas why this application would be crashing at 3GB? Is there any more diagnostics I should be doing? I would ultimately like to port this to 64-bit for a number of reasons, but it is a big undertaking for my organization, and I'd like to better understand what's going on here.

View 3 Replies View Related

Programming :: Didn't Change The Original Value Of The Pointer It Was Trying To Use For Allocation?

Feb 8, 2011

A friend working in HPC environments commented me that he had an issue regarding the use of the malloc() function.What issue?He told me that he has had cases in where malloc() instead of returning a NULL pointer on failure, simply didn't change the original value of the pointer it was trying to use for allocation, thus forcing him to initialize pointers to be allocated with malloc() to NULL, so that he could be sure that if malloc() fails, a test for NULL would make sense.

View 12 Replies View Related

Programming :: Processor Priority Level For Algorithm For Buffer Allocation

Jan 9, 2010

The algorithm for reading and writing disk blocks use the algorithm getblk to allocate buffers from the pool. In the algorithm getblk, if the kernel removes a buffer from the free list, it must raise the processor priority level to block out interrupts before checking the free list. Why ?Where can i find the C implementation of the above algorithm for buffer allocation in the linux source code ?

View 1 Replies View Related

Programming :: Memory Leaks - Glibc Detected - ./SuffixTree: Malloc() - Memory Corruption - 0x00

Mar 21, 2011

I am new to C and linux. My code below does arbitary writes but I cant figure out where or how it does it.

I am calling the insertNode() function with seq = 'MISSISSPPI$' and alphabets = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ$'

Code:

Weird behaviour I should mention is that when I check for NULL pointer in node->child[index], the unassigned values are not null anymore, they point to arbitary memory.

View 12 Replies View Related

Programming :: Write A Script That Can Show Me Total Memory Vs Used Memory?

Apr 13, 2010

How do I write a script for my Linux that can show me total memory vs used memory and have it email me results if it's over 70 percent?

View 2 Replies View Related

Programming :: SHM Memory Counted As Cache Memory With Kernel 2.6.18?

Aug 25, 2010

Is that possible that SHM shared memory is counted as cache memory on Linux with kernel 2.6.18?If find it really odd since this memory is not file backed, but I have a piece of code that loads data using shm_open+mmap, and it generates an amount of cache memory in /proc/meminfo that corresponds exactly to the amount of shared memory (I load that data from a file but I am using posix_fadvise(fd,0,0,POSIX_FADV_DONTNEED) to ensure this file is not cached and I made sure that it is working as expected). As far as I know SHM memory was not tagged as cache memory with kernel 2.6.9.If it is the case it is really unfortunate since normally cache memory can be considered to be part of the "available" memory since it can be flushed promptly but this is clearly not the case with SHM memory... Is there an easy way to get the total amount of used SHM memory on a system?

View 4 Replies View Related

Fedora :: ANSI BBS In Gnome Terminal ?

Sep 24, 2010

I am a former Sysop of a BBS and currently resurrecting the BBS. I have been looking for a way to get Gnome Terminal in Fedora 13 configured to support ANSI BBS emulation.

Back in the DOS days, we just loaded ANSI.SYS and ran our terminal software (like Procomm Plus or Qmodem), but I am hoping someone has done this and can help me set it up.

I have already tried Qterrm and the "latest" syncterm. Neither of these worked right. Syncterm hasn't been updated since 2009, so I really don't want to mess too much with that one.

I know you can terminal.app in Mac OS X to do it, so I figure we can too. I REALLY want gnome terminal to be the way to do it.

View 5 Replies View Related

Software :: Less - ANSI Colors And Search

Aug 2, 2010

I'm having an annoying issue with less. What I want is to view logs with important stuff color coded, and be able to correctly use less's search function.

What happens is that less correctly displays color coded text, but offsets the search highlighting.

For instance, if I run "ls -l --color=always | less -R", and then search for some text, the highlighting will be offset if that text (or any text before it) is colored.

I tried forcing LESSANSIENDCHARS by doing a "export LESSANSIENDCHARS=m", but that didn't work.

"less --version" gives me "less 382+iso254", and I am running "SUSE LINUX Enterprise Server 9 (x86_64)".

View 3 Replies View Related

General :: Printing Transcript With Ansi Escape Sequence?

Aug 8, 2010

Is there a way to print a transcript generated using script that is coloured using ansi escape sequences while preserving the colours?

I am on OS X 10.6, but any tool that works on OS X or on Linux that can print or create a pdf file will be extremely helpful.

View 1 Replies View Related

Software :: Text Editor To Display ANSI Color?

Mar 7, 2009

I'm looking for a text editor that when displaying a document will parse any ANSI color codes it comes across into the correct colors rather than just show the codes in the ^[[xx;xx;xxm format

can anyone recommend something?

View 3 Replies View Related

General :: Terminal That Supports ANSI Italic Escape Code?

Oct 29, 2010

I would like to replace gvim with vim in the terminal. One of the nice things about gvim is that it is able to display text using italics.

Vim allows setting an ANSI escape code for italics (e[3m), but this does not work in gnome-terminal. Is there a terminal emulator that supports the ANSI escape code for italics?

View 1 Replies View Related

General :: Redefine The Way ANSI Colors Are Shown In A Terminal Emulator?

Jun 8, 2011

I'd like to redefine the actual colors that ANSI escape sequences show, i.e. I'd like to personalize what "light red" means and render it as, say, orange. Is there any terminal emulator that works under linux that allows me to do this? how?

View 1 Replies View Related

Programming :: Memory Leak In C++?

Mar 3, 2011

I'm currently developping a program in C++, using Qt, for an embedded board (SBC9261).It works well but crashes after some time, due to a system memory overload (my program uses more and more memory until 100%, when it crashes).I've been able to figure out the source of the memory leak :The function f is called by my program every second. f instanciates a new object (a QImage from the Qt lib), does a bunch of processing on it, and returns it to the calling function :

Code:
QImage *MyClass::f(QString filename) {// Open image
QImage *image = new QImage(filename);

[code]....

View 5 Replies View Related

Programming :: Regarding Memory Errors In G++?

Jul 22, 2011

I have a general question regarding memory errors. I frequently ran into memory errors such as seg fault, double free, etc. Sometimes I got the following traces for example.

*** glibc detected *** /mnt/click: free(): invalid pointer: 0xb7ed8450 ***
======= Backtrace: =========
/lib/libc.so.6[0xb7dff905]
/lib/libc.so.6[0xb7e011a3]

[code]....

Then, I just run gdb, valgrind things and suddenly I started ask questions myself that what are those traces and how can I analyze?

View 1 Replies View Related

Programming :: How To Get Usage Of CPU Memory?

Jan 11, 2009

i am wondering How to get usage of CPU, Memory in linux environment? So would you able to tell me the ways?

View 10 Replies View Related

CentOS 5 :: Xen Freezes On PCI Allocation?

May 30, 2010

I've installed XEN according to this tutorial: [URL] on the first XEN boot, it freezes for a very long time on:

allocating pci resources starting at a8000000 (gap: a0000000:5ec00000)

View 4 Replies View Related

Programming :: Shared Memory IPC Variations ?

Apr 19, 2010

I have 2 applications that send and receive messages through shared memory IPC. When I run the app ..it works but the number of messages per sec keeps changing drastically sometimes it is 400-500 per sec..then 800 then 1200 then 2000. is this normal with SHM IPC or could it be a code related issue.

View 9 Replies View Related

Programming :: Getting The CPU & (Virtual) Memory Of A Process?

Aug 23, 2010

Is there any program which gets the CPU and memory of a process ?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved