Search Results

Search found 12267 results on 491 pages for 'out of memory'.

Page 132/491 | < Previous Page | 128 129 130 131 132 133 134 135 136 137 138 139  | Next Page >

  • Cant free memory.

    - by atch
    In code: int a[3][4] = {1,2,3,4, 5,6,7,8, 9,10,11,12}; template<class T, int row, int col> void invert(T a[row][col]) { T* columns = new T[col]; T* const free_me = columns; for (int i = 0; i < col; ++i) { for (int j = 0; j < row; ++j) { *columns = a[j][i]; ++columns;//SOMETIMES VALUE IS 0 } } delete[] free_me;//I'M GETTING ERROR OF HEAP ABUSE IN THIS LINE } int main(int argc, char* argv[]) { invert<int,3,4>(a); } I've observed that while iterating, value of variable columns equals zero and I think thats the problem. Thanks for your help.

    Read the article

  • Java Out of memory - Out of heap size

    - by user1907849
    I downloaded the sample program , for file transfer between the client and server. When I try running the program with 1 GB file , I get the Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at Client.main(Client.java:31). Edit: Line no 31: byte [] mybytearray = new byte [FILE_SIZE]; public final static int FILE_SIZE = 1097742336; // receive file long startTime = System.nanoTime(); byte [] mybytearray = new byte [FILE_SIZE]; InputStream is = sock.getInputStream(); fos = new FileOutputStream(FILE_TO_RECEIVED); bos = new BufferedOutputStream(fos); bytesRead = is.read(mybytearray,0,mybytearray.length); current = bytesRead; do { bytesRead = is.read(mybytearray, current, (mybytearray.length-current)); if(bytesRead >= 0) current += bytesRead; } while(bytesRead > -1); bos.write(mybytearray, 0 , current); bos.flush(); Is there any fix for this?

    Read the article

  • dynamic memory allocation of 2d array in which columns are of different size

    - by vishal kumar
    i want to create a 2d array dynamically in c++ language. But in that 2d array columns should be of different size. i mean to say that 2d array should not be in M * N. It should be something like.... 1 2 next line 3 4 5 next line 2 3 4 5 next line 5 next line 4 5 7 I am able to create 2d array in above manner but how to display content of array continously create a problem for me. Please anyone explain me how to come up with this problem.

    Read the article

  • UseConcMarkSweepGC verbose gc output shows memory drops

    - by user1864747
    I have an application for which I have enabled GC logging. The heap appears to grow then takes a sudden drop, but does not log a Full GC. If there some startup parameter that I can enable that will show me what GC event is reducing the heap size? My environment: Linux 64-Bit, java 1.6.0_31, Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode) VM args: -server -Xms2560m -Xmx2560m -XX:+UseConcMarkSweepGC -XX:MaxPermSize=256m -XX:-PrintGC -XX: -PrintGCDetails -XX:-PrintGCTimeStamps -Xloggc:/xxxxx/gc.log -Dsun.rmi.dgc.client.gcInterval=86400000 -Dsun.rmi.dgc.server.gcInterval=86400000 3057.609: [GC 2397254K->2385777K(2619328K), 0.0572310 secs] 3058.898: [GC 2402801K->2391301K(2619328K), 0.0566620 secs] 3059.940: [GC 2408325K->2397156K(2619328K), 0.0534080 secs] 3059.995: [GC 2397265K(2619328K), 0.0069950 secs] 3065.635: [GC 2414180K->2404934K(2619328K), 0.0732700 secs] 3065.849: [GC 2419994K(2619328K), 0.1150630 secs] 3070.248: [GC 1593931K->1591825K(2619328K), 0.1084230 secs] 3072.440: [GC 1608552K->1606431K(2619328K), 0.0533140 secs] 3087.759: [GC 1623455K->1614544K(2619328K), 0.0215850 secs] What event is causing the heap to shrink between the output at 3065.849 and 3070.248? Is there a VM param that will log it? I tried adding -verbose:gc but that does not change the output.

    Read the article

  • c++ figuring out memory layout of members programatically

    - by anon
    Suppose in one program, I'm given: class Foo { int x; double y; char z; }; class Bar { Foo f1; int t; Foo f2; }; int main() { Bar b; bar.f1.z = 'h'; bar.f2.z = 'w'; ... some crap setting value of b; FILE *f = fopen("dump", "wb"); // c-style file fwrite(&b, sizeof(Bar), 1, f); } Suppose in another program, I have: int main() { File *f = fopen("dump", "rb"); std::string Foo = "int x; double y; char z;"; std::string Bar = "Foo f1; int t; Foo f2;"; // now, given this is it possible to read out // the value of bar.f1.z and bar.f2.z set earlier? } WHat I'm asking is: given I have the types of a class, can I figure out how C++ lays it out?

    Read the article

  • [Visual C++]Forcing memory alignment of variables/data-structures

    - by John
    I'm looking at using SSE and I gather aligning data on 16byte boundaries is recommended. There are two cases to consider: float data[4]; struct myystruct { float x,y,z,w; }; I'm not sure the first case can be done explicitly, though there's perhaps a compiler option I could use? In the second case I remember being able to control packing in old versions of GCC several years back, is this still possible?

    Read the article

  • some thing wrong with memory?

    - by Rocker
    Hi there I am developing a game using Cocos2D. I got some error out of sudden after few time successfully played the game. And When i debugged it gives the error called EXC_BAD_ACCESS. here is the code. -(void) winGame { //the debug stopped here... WinningScene *winner = [WinningScene node]; [[Director sharedDirector] replaceScene:[FadeTransition transitionWithDuration:1.0 scene:winner]]; } if ((touchCount > 0 && touchCount ==2) && (rangeY2 > 0.0 && rangeY2 < 20.0)) { bras++; if (bras == 1) { //[self winGame]; [self runAction:[Sequence actionOne:[DelayTime actionWithDuration:0.5] two: [CallFunc actionWithTarget:self selector:@selector(winGame)]]]; } Could u guys tell me why ?

    Read the article

  • how to allocate memory for struct itself, and its members

    - by Jack
    I have this struct: struct foo { char *a; char *b; char *c; char *d; }; it's possible allocate space for struct itself and its members instead of e.g, struct foo f; f.a = malloc(); f.b = malloc(); f.c = malloc(); f.d = malloc(); strcpy(f.a, "a"); strcpy(f.b, "b"); //.. something like this(of couse that it doesn't works): struct foo f = malloc(sizeof(struct f)); strpcy(f.a, "a"); //etc

    Read the article

  • Memory error, access violation.

    - by Ordo
    Hello! I'm learning C on my own and as a exercise i have written a program but it does not work. The program is splitted into 3 parts. A header file, a main file for executing the program a file to define the functions. I'm not using all the functions yet but that shouldn't be the problem. Here is my header file, nothing special in it. #ifndef EMPLOYEE_H #define EMPLOYEE_H struct Employee { char first[21]; char last[21]; char title[21]; int salary; }; struct Employee* createEmployee(char*, char*, char*, int); // Creates a struct Employee object on the heap. char* getfirstname (struct Employee*); char* getlastname (struct Employee*); char* gettitle (struct Employee*); int getsalary (struct Employee*); void setfirstname (struct Employee*, char*); void setlastname (struct Employee*, char*); void settitle (struct Employee*, char*); void setsalary (struct Employee*, int); void printEmployee(struct Employee*); #endif In this file i define the functions and how they work: #include "7.1.h" #include <stdio.h> #include <stdlib.h> #include <string.h> struct Employee* createEmployee(char* first, char* last, char* title, int salary) // Creates a struct Employee object on the heap. { struct Employee* p = (struct Employee*) malloc(sizeof(struct Employee)); if (p != NULL) { strcpy(p->first, first); strcpy(p->last, last); strcpy(p->title, title); p->salary, salary; } return p; } char* getfirstname (struct Employee* p) { if (p != NULL) return p ? p->first : ""; } char* getlastname (struct Employee* p) { if (p != NULL) return p ? p->last : ""; } char* gettitle (struct Employee* p) { if (p != NULL) return p ? p->title : ""; } int getsalary (struct Employee* p) { if (p != NULL) return p ? p->salary : 0; } void setfirstname (struct Employee* p, char* first) { if (p != NULL) strcpy(p->first, first); } void setlastname (struct Employee* p, char* last) { if (p != NULL) strcpy(p->last, last); } void settitle (struct Employee* p, char* title) { if (p != NULL) strcpy(p->title, title); } void setsalary (struct Employee* p, char* salary) { if (p != NULL) p->salary, salary; } void printEmployee(struct Employee* p) { if (p != NULL) { printf("%s, %s, %s, %d", p->first, p->last, p->salary, p->salary ); } } And the last file is used to executed the program/functions: #include "7.1.h" #include <stdio.h> #include <stdlib.h> int main () { char decision; struct Employee emp; struct Employee* emps[3]; for ( int i = 0; i < 1; i ++) { printf("Please type in the emplooyes data.\nFirstname:"); scanf("%s", emp.first); printf("Lastname:"); scanf("%s", emp.last); printf("Title:"); scanf("%s", emp.title); printf("Salary:"); scanf("%d", &emp.salary); emps[i] = createEmployee(emp.first, emp.last, emp.title, emp.salary); } printf("Do you want to print out your information? (Y/N):"); scanf("%c", &decision); if (decision == 'y' || decision == 'Y') { printEmployee(emps[1]); } } I don't know what the problem is. I 'm always getting the following error message after typing in first, last, title and salary for the first time. The error is written in german. It means: Unhandled exception at 0x102de42e (msvcr100d.dll) in 7.1.exe: 0xC0000005: Access violation when writing to 0xCCCCCCCC position. I could fix the first problem with the hints given below. Now when i want to print out the employee data using the function:printEmployee(emps[1]);, I get the same kind of error with access violation.

    Read the article

  • Why does MS-DOS tells me I need extended memory and thinks a file is read-only? [closed]

    - by Jake Inc.
    I am running a .COM file on a MS-DOS 6.22 boot USB drive When I run it on my laptop the program works fine but when I run it on my desktop I get error 40 not enough extended memory. When I go to the memory tab in GUI I try to switch none to auto, but I get the error "This file might be read-only". It's not read-only, when I put it on my desktop I change the settings and the new settings are in a .pif I can't run .pif in MS-DOs so I need to Change the .exe not create a .pif. Change the amount of extended memory all files have on my MS-DOS. On my laptop there is no memory tab, the only real difference is my laptop is x64. Thanks for helping but I think teh x64 bit has nothing to do with it I dont eve nthink iits in 64 bit mode because Im using a boot USB. What i need to is listed above, thanks for helping.

    Read the article

  • Freeing memory with Pointer Arithmetic

    - by Breedly
    C++ newb here. I'm trying to write my own implementation of an array using only pointers, and I've hit a wall I don't know how to get over. My constructor throws this error array.cpp:40:35: error: invalid conversion from ‘int*’ to ‘int’ [-fpermissive] When my array initializes I want it to free up all the spaces in the array for ints. Array::Array(int theSize){ size = theSize; int *arrayPointer = new int; int index = 0; while(theSize > index){ *(arrayPointer + index) = new int; //This is the trouble line. ++index; } } What am I doing wrong stackoverflow?

    Read the article

  • WPF databind in memory image to Image control

    - by Ready Cent
    I am using a DataGrid and trying to do the following Databinding <DataTemplate> <Grid> <Image> <Image.Source> <BitmapImage UriSource="{Binding Data.CustomImage}" CacheOption="OnLoad" /> </Image.Source> </Image> </Grid> </DataTemplate> CustomImage is of type BitmapImage. When I run I get the error: Initialization of 'System.Windows.Media.Imaging.BitmapImage' threw an exception. The thing is that these images are stored as resources in a different assembly so I can't just point to a location on disk

    Read the article

  • Same memory space being allocated again & again while using malloc()

    - by shadyabhi
    In each loop iteration, variable j is declared again and again. Then why is its address remaining same? Shouldn't it be given some random address each time? Is this compiler dependent? #include<stdio.h> #include<malloc.h> int main() { int i=3; while (i--) { int j; printf("%p\n", &j); } return 0; } Testrun:- shadyabhi@shadyabhi-desktop:~/c$ gcc test.c shadyabhi@shadyabhi-desktop:~/c$ ./a.out 0x7fffc0b8e138 0x7fffc0b8e138 0x7fffc0b8e138 shadyabhi@shadyabhi-desktop:~/c$

    Read the article

  • cuda 5.0 namespaces for contant memory variable usage

    - by Psypher
    In my program I want to use a structure containing constant variables and keep it on device all long as the program executes to completion. I have several header files containing the declaration of 'global' functions and their respective '.cu' files for their definitions. I kept this scheme because it helps me contain similar code in one place. e.g. all the 'device' functions required to complete 'KERNEL_1' are separated from those 'device' functions required to complete 'KERNEL_2' along with kernels definitions. I had no problems with this scheme during compilation and linking. Until I encountered constant variables. I want to use the same constant variable through all kernels and device functions but it doesn't seem to work. ########################################################################## CODE EXAMPLE ########################################################################### filename: 'common.h' -------------------------------------------------------------------------- typedef struct { double height; double weight; int age; } __CONSTANTS; __constant__ __CONSTANTS d_const; --------------------------------------------------------------------------- filename: main.cu --------------------------------------------------------------------------- #include "common.h" #include "gpukernels.h" int main(int argc, char **argv) { __CONSTANTS T; T.height = 1.79; T.weight = 73.2; T.age = 26; cudaMemcpyToSymbol(d_consts, &T, sizeof(__CONSTANTS)); test_kernel <<< 1, 16 >>>(); cudaDeviceSynchronize(); } --------------------------------------------------------------------------- filename: gpukernels.h --------------------------------------------------------------------------- __global__ void test_kernel(); --------------------------------------------------------------------------- filename: gpukernels.cu --------------------------------------------------------------------------- #include <stdio.h> #include "gpukernels.h" #include "common.h" __global__ void test_kernel() { printf("Id: %d, height: %f, weight: %f\n", threadIdx.x, d_const.height, d_const.weight); } When I execute this code, the kernel executes, displays the thread ids, but the constant values are displayed as zeros. How can I fix this?

    Read the article

  • Same memory space being allocated again & again

    - by shadyabhi
    In each loop iteration, variable j is declared again and again. Then why is its address remaining same? Shouldn't it be given some random address each time? Is this compiler dependent? #include<stdio.h> #include<malloc.h> int main() { int i=3; while (i--) { int j; printf("%p\n", &j); } return 0; } Testrun:- shadyabhi@shadyabhi-desktop:~/c$ gcc test.c shadyabhi@shadyabhi-desktop:~/c$ ./a.out 0x7fffc0b8e138 0x7fffc0b8e138 0x7fffc0b8e138 shadyabhi@shadyabhi-desktop:~/c$

    Read the article

  • c++ macros with memory?

    - by anon
    Is it possible to define macros write_foo(A); and read_foo(); so that: WRITE_FOO(hello); code_block_1; READ_FOO(); code_block_2; READ_FOO(); WRITE_FOO(world); code_block_3; READ_FOO(); code_block_4; READ_FOO(); expands into: code_block_1; hello; code_block_2; hello; code_boock_3; world; code_block_4; world; ? Thanks!

    Read the article

  • Why can't I reserve 1,000,000,000 in my vector ?

    - by vipersnake005
    When I type in the foll. code, I get the output as 1073741823. #include <iostream> #include <vector> using namespace std; int main() { vector <int> v; cout<<v.max_size(); return 0; } However when I try to resize the vector to 1,000,000,000, by v.resize(1000000000); the program stops executing. How can I enable the program to allocate the required memory, when it seems that it should be able to? I am using MinGW in Windows 7. I have 2 GB RAM. Should it not be possible? In case it is not possible, can't I declare it as an array of integers and get away? BUt even that doesn't work. Another thing is that, suppose I would use a file(which can easily handle so much data ). How can I let it read and write and the same time. Using fstream file("file.txt', ios::out | ios::in ); doesn't create a file, in the first place. But supposing the file exists, I am unable to use to do reading and writing simultaneously. WHat I mean is this : Let the contents of the file be 111111 Then if I run : - #include <fstream> #include <iostream> using namespace std; int main() { fstream file("file.txt",ios:in|ios::out); char x; while( file>>x) { file<<'0'; } return 0; } Shouldn't the file's contents now be 101010 ? Read one character and then overwrite the next one with 0 ? Or incase the entire contents were read at once into some buffer, should there not be atleast one 0 in the file ? 1111110 ? But the contents remain unaltered. Please explain. Thank you.

    Read the article

  • Set argument pointer to point to new memory inside a function (without returning it) IN C

    - by user321605
    Hello, Hopefully my title was descriptive enough to attract the right help. I want to write a function that will return 1 thing, and modify a provided pointer in another. My current function declaration is . . . char * afterURL replaceURLS(char * body) What I want to do is copy all of body's data into a new string, and set body to point to this new data. I then want afterURL to point to a location within the new string. My issue is getting the actual pointer that is passed in to this function to point to the new data. Thanks in advance! Rob

    Read the article

  • A nuts and bolts reference to C# performance and memory use

    - by phil
    I wonder if anyone could point me in the direction where I can read about the nuts and bolts of C#. What I'm interested in learning are method call costs, what it costs to create objects and such. My aim of learning this is to get a better understanding of how increase the performance of an application and get a better understanding of how the C# language works. The reference should preferable be a book, a book that I can read cover to cover.

    Read the article

  • Help with memory leak (malloc)

    - by user146780
    I'v followed a tutorial to use OGL tesselaton. In one of the callbacks there is a malloc and it creates a leak every time I render a new frame. void CALLBACK combineCallback(GLdouble coords[3], GLdouble *vertex_data[4], GLfloat weight[4], GLdouble **dataOut) { GLdouble *vertex; vertex = (GLdouble *) malloc(6 * sizeof(GLdouble)); vertex[0] = coords[0]; vertex[1] = coords[1]; vertex[2] = coords[2]; for (int i = 3; i < 6; i++) { vertex[i] = weight[0] * vertex_data[0][i] + weight[1] * vertex_data[0][i] + weight[2] * vertex_data[0][i] + weight[3] * vertex_data[0][i]; } *dataOut = vertex; } I'v tried to free(vertex) but then the polygons did not render. I also tried allocating on the heap then doing delete(vertex) but then the polygon rendered awkwardly. I'm not sure what to do. Thanks

    Read the article

  • memory management: am i doing something wrong here?

    - by z s
    Hi, In a very small number of cases in my iphone app, I get a crash after the for loop in the code below: ABAddressBookRef addressBookInit = ABAddressBookCreate(); CFMutableArrayRef abContacts = (CFMutableArrayRef)ABAddressBookCopyArrayOfAllPeople(addressBookInit); // get array of all contacts CFArraySortValues (abContacts, CFRangeMake(0, CFArrayGetCount(abContacts)), (CFComparatorFunction)ABPersonComparePeopleByName, (void *)ABPersonGetSortOrdering()); NSArray *copypeople = (NSArray *) abContacts; NSMutableArray *tempTheadlist = [[NSMutableArray alloc] init]; for (int i=0; i < copypeople.count; i++) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; ABRecordRef record = [copypeople objectAtIndex:i]; if (blah blah) [tempThreadList addObject: someObject]; [pool release]; } // POINT OF CRASH AFTER LOOP ENDS if (tempTheadlist.count > 0) [NSThread detachNewThreadSelector: @selector(loading_pictures:) toTarget:self withObject:tempTheadlist]; [tempTheadlist release]; [copypeople release]; CFRelease(addressBookInit); Any reason why it should crash at any point here?

    Read the article

  • Difference between macros and functions in C in relation to instruction memory and speed

    - by DAHANS
    To my understanding the difference between a macro and a function is, that a macro-call will be replaced by the instruction in the definition, and a function does the whole push, branch and pop -thing. Is this right, or have I understand something wrong? Additionally, if this is right, it would mean, that macros would take more space, but would be faster (because of the lack of the push,branch and pop instructions.), wouldn't it?

    Read the article

  • Sending a file from memory (rather than disk) over HTTP using libcurl

    - by cinek1lol
    Hi! I would like to send pictures via a program written in C + +. - OK WinExec("C:\\curl\\curl.exe -H Expect: -F \"fileupload=@C:\\curl\\ok.jpg\" -F \"xml=yes\" -# \"http://www.imageshack.us/index.php\" -o data.txt -A \"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1\" -e \"http://www.imageshack.us\"", NULL); It works, but I would like to send the pictures from pre-loaded carrier to a variable char (you know what I mean? First off, I load the pictures into a variable and then send the variable), cause now I have to specify the path of the picture on a disk. I wanted to write this program in c++ by using the curl library, not through exe. extension. I have also found such a program (which has been modified by me a bit) #include <stdio.h> #include <string.h> #include <iostream> #include <curl/curl.h> #include <curl/types.h> #include <curl/easy.h> int main(int argc, char *argv[]) { CURL *curl; CURLcode res; struct curl_httppost *formpost=NULL; struct curl_httppost *lastptr=NULL; struct curl_slist *headerlist=NULL; static const char buf[] = "Expect:"; curl_global_init(CURL_GLOBAL_ALL); /* Fill in the file upload field */ curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "send", CURLFORM_FILE, "nowy.jpg", CURLFORM_END); curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "nowy.jpg", CURLFORM_COPYCONTENTS, "nowy.jpg", CURLFORM_END); curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "submit", CURLFORM_COPYCONTENTS, "send", CURLFORM_END); curl = curl_easy_init(); headerlist = curl_slist_append(headerlist, buf); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "http://www.imageshack.us/index.php"); if ( (argc == 2) && (!strcmp(argv[1], "xml=yes")) ) curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); res = curl_easy_perform(curl); curl_easy_cleanup(curl); curl_formfree(formpost); curl_slist_free_all (headerlist); } system("pause"); return 0; }

    Read the article

< Previous Page | 128 129 130 131 132 133 134 135 136 137 138 139  | Next Page >