Search Results

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

Page 247/491 | < Previous Page | 243 244 245 246 247 248 249 250 251 252 253 254  | Next Page >

  • Does Monitor.Wait ensure that fields are re-read?

    - by Marc Gravell
    It is generally accepted (I believe!) that a lock will force any values from fields to be reloaded (essentially acting as a memory-barrier or fence - my terminology in this area gets a bit loose, I'm afraid), with the consequence that fields that are only ever accessed inside a lock do not themselves need to be volatile. (If I'm wrong already, just say!) A good comment was raised here, questioning whether the same is true if code does a Wait() - i.e. once it has been Pulse()d, will it reload fields from memory, or could they be in a register (etc). Or more simply: does the field need to be volatile to ensure that the current value is obtained when resuming after a Wait()? Looking at reflector, Wait calls down into ObjWait, which is managed internalcall (the same as Enter). The scenario in question was: bool closing; public bool TryDequeue(out T value) { lock (queue) { // arbitrary lock-object (a private readonly ref-type) while (queue.Count == 0) { if (closing) { // <==== (2) access field here value = default(T); return false; } Monitor.Wait(queue); // <==== (1) waits here } ...blah do something with the head of the queue } } Obviously I could just make it volatile, or I could move this out so that I exit and re-enter the Monitor every time it gets pulsed, but I'm intrigued to know if either is necessary.

    Read the article

  • When is a Web Service constructor called? [Java Netbeans 6.7.1 & Tomcat 6.0.18]

    - by Shaitan00
    I am migrating a Java RMI application to Java Web Service (school assignment) and I've encountered an issue... Currently my Java Server creates an instance of the Remote Object, this object has a constructor and takes a parameter (int ID) which tells it which database to load in memory - works like a charm ... Now, migrating this to Web Services is causing my a problem - first I needed to add a default constructor because it wouldn't deploy without it, and then while doing some reading all these discussions about "stateless web services" kept coming up ... For example, if I "start" my webservice with parameter(0) it would load from Databse 0 and all requests from Clients would be done using that data... I want this to only happen when I start the WebService and NOT everytime the client connects... Loading from the DB is expensive and takes time, so I want to do it once so that clients when they connect just deal with the data in memory ... This is how it works with my Java RMI .... but can this also work with Web Services? Any advice would be much appreciated. Thanks,

    Read the article

  • Creating new image in a loop using OpenCV

    - by user565415
    I am programing some image conversion code with OpenCV and I don't know how can I create image memory buffer to load image on every iteration. I have number of iteration (maxImNumber) and I have an input image. In every loop program must create image that is resized and modified input image. Here is some basic code (concept). for (int imageIndex = 0; imageIndex < maxImNumber; imageIndex++){ cvCopy(inputImage, images[imageIndex], 0); cvReleaseImage(&inputImage); images[imageIndex+1] = cvCreateImage(cvSize((image[imageIndex]->width)/2, image[imageIndex]->height), IPL_DEPTH_8U, 1); for (i=1; i < image[imageIndex]->height; i++) { index = 0; // for(j=0; j < image[imageIndex]->width ; j=j+2){ // doing some basic matematical operation on image content and store it to new image images[imageIndex+1][i][index] = (image[imageIndex][i][j] + image[imageIndex][i][j+2])/2; index++ } } inputImage = cvCreateImage(cvSize((image[imageIndex+1]->width), image[imageIndex]->height), IPL_DEPTH_8U, 1); cvCopy(images[imageIndex+1], inputImage, 0); } Can somebody, please, explain how can I create this image buffer (images[]) and allocate memory for it. Also how can I access any image in this buffer? Thank you very much in advance!

    Read the article

  • Access array of c-structs using Python ctypes

    - by sadris
    I have a C-function that allocates memory at the address passed to and is accessed via Python. The pointer contents does contain an array of structs in the C code, but I am unable to get ctypes to access the array properly beyond the 0th element. How can I get the proper memory offset to be able to access the non-zero elements? Python's ctypes.memset is complaining about TypeErrors if I try to use their ctypes.memset function. typedef struct td_Group { unsigned int group_id; char groupname[256]; char date_created[32]; char date_modified[32]; unsigned int user_modified; unsigned int user_created; } Group; int getGroups(LIBmanager * handler, Group ** unallocatedPointer); ############# python code below: class Group(Structure): _fields_ = [("group_id", c_uint), ("groupname", c_char*256), ("date_created", c_char*32), ("date_modified", c_char*32), ("user_modified", c_uint), ("user_created", c_uint)] myGroups = c_void_p() count = libnativetest.getGroups( nativePointer, byref(myGroups) ) casted = cast( myGroups, POINTER(Group*count) ) for x in range(0,count): theGroup = cast( casted[x], POINTER(Group) ) # this only works for the first entry in the array: print "~~~~~~~~~~" + theGroup.contents.groupname Related: Access c_char_p_Array_256 in Python using ctypes

    Read the article

  • NVelocity (or Velocity) as a stand-alone formula evaluator

    - by dana
    I am using NVelocity in my application to generate html emails. My application has an event-driven model, where saving and/or updating of objects causes these emails to be sent out. Each event can trigger zero, one or multiple multiple emails. I want to be able to configure which emails get sent out at run-time without having to modify code. I was thinking I could leverage the NVelocity #if() directive to do this. Here is my idea... Step 1) Prior to email sending, the administrator must configure a formula for NVelocity to evaluate. For example: $User.FirstName == "Jack" Step 2) When an object is saved or created, build an NVelocity template in memory based on the input formula. For example: String formula = GetFormulaFromDB(); // $User.FirstName == "Jack" String templ = "#if( " + formula + ") 1 #else 0 #end"; Step 3) Execute the NVelocity engine in memory against the template. Check the results to see if we have to send the email: String result = VelocityMerge(templ); // utility function if( result.Trim() == "1" ) { SendEmail(); } I know this is not exactly what NVelocity was intended to do, but I think it just might work :) One of the benefits of doing things this way is that the same syntax can be used for the formula as is used inside the template. Does anybody have any words of caution or suggestions? Is there a way to execute the #if() directive without jumping through hoops like I have above? Is there a recommended way to validate the formula syntax ahead of time? Thanks.

    Read the article

  • Sharing a global/static variable between a process and DLL

    - by minjang
    I'd like to share a static/global variable only between a process and a dll that is invoked by the process. The exe and dll are in the same memory address space. I don't want the variable to be shared among other processes. Elaboration of the problem: Say that there is a static/global variable x in a.cpp. Both the exe foo.exe and the dll bar.dll have a.cpp, so the variable x is in both images. Now, foo.exe dynamically loads (or statically) bar.dll. Then, the problem is whether the variable x is shared by the exe and dll, or not. In Windows, these two guys never share the x: the exe and dll will have a separate copy of x. However, in Linux, the exe and dll do share the variable x. Unfortunately, I want the behavior of Linux. I first considered using pragma data_seg on Windows. However, even if I correctly setup the shared data segment, foo.exe and bar.dll never shares the x. Recall that bar.dll is loaded into the address space of foo.exe. However, if I run another instance of foo.exe, then x is shared. But, I don't want x to be shared by different processes. So, using data_seg was failed. I may it use a memory-mapped file by making an unique name between exe and dll, which I'm trying now. Two questions: Why the behavior of Linux and Windows is different? Can anyone explain more about this? What would be most easiest way to solve this problem on Windows?

    Read the article

  • Algorithm to determine if array contains n...n+m?

    - by Kyle Cronin
    I saw this question on Reddit, and there were no positive solutions presented, and I thought it would be a perfect question to ask here. This was in a thread about interview questions: Write a method that takes an int array of size m, and returns (True/False) if the array consists of the numbers n...n+m-1, all numbers in that range and only numbers in that range. The array is not guaranteed to be sorted. (For instance, {2,3,4} would return true. {1,3,1} would return false, {1,2,4} would return false. The problem I had with this one is that my interviewer kept asking me to optimize (faster O(n), less memory, etc), to the point where he claimed you could do it in one pass of the array using a constant amount of memory. Never figured that one out. Along with your solutions please indicate if they assume that the array contains unique items. Also indicate if your solution assumes the sequence starts at 1. (I've modified the question slightly to allow cases where it goes 2, 3, 4...) edit: I am now of the opinion that there does not exist a linear in time and constant in space algorithm that handles duplicates. Can anyone verify this? The duplicate problem boils down to testing to see if the array contains duplicates in O(n) time, O(1) space. If this can be done you can simply test first and if there are no duplicates run the algorithms posted. So can you test for dupes in O(n) time O(1) space?

    Read the article

  • pointer, malloc and char in C

    - by user2534078
    im trying to copy a const char array to some place in the memory and point to it . lets say im defining this var under the main prog : char *p = NULL; and sending it to a function with a string : myFunc(&p, "Hello"); now i want that at the end of this function the pointer will point to the letter H but if i puts() it, it will print Hello . here is what i tried to do : void myFunc(char** ptr , const char strng[] ) { *ptr=(char *) malloc(sizeof(strng)); char * tmp=*ptr; int i=0; while (1) { *ptr[i]=strng[i]; if (strng[i]=='\0') break; i++; } *ptr=tmp; } i know its a rubbish now, but i would like to understand how to do it right, my idea was to allocate the needed memory, copy a char and move forward with the pointer, etc.. also i tried to make the ptr argument byreferenec (like &ptr) but with no success due to a problem with the lvalue and rvalue . the only thing is changeable for me is the function, and i would like not to use strings, but chars as this is and exercise . thanks for any help in advance.

    Read the article

  • Can g++ fill uninitialized POD variables with known values?

    - by Bob Lied
    I know that Visual Studio under debugging options will fill memory with a known value. Does g++ (any version, but gcc 4.1.2 is most interesting) have any options that would fill an uninitialized local POD structure with recognizable values? struct something{ int a; int b; }; void foo() { something uninitialized; bar(uninitialized.b); } I expect uninitialized.b to be unpredictable randomness; clearly a bug and easily found if optimization and warnings are turned on. But compiled with -g only, no warning. A colleague had a case where code similar to this worked because it coincidentally had a valid value; when the compiler upgraded, it started failing. He thought it was because the new compiler was inserting known values into the structure (much the way that VS fills 0xCC). In my own experience, it was just different random values that didn't happen to be valid. But now I'm curious -- is there any setting of g++ that would make it fill memory that the standard would otherwise say should be uninitialized?

    Read the article

  • How to "pin" C++/CLI pointers

    - by Kumar
    I am wrapping up a class which reading a custom binary data file and makes the data available to a .net/c# class However a couple of lines down the code, i start getting the memory access violation error which i believe is due to the GC moving memory around, the class is managed Here's the code if ( ! reader.OpenFile(...) ) return ; foreach(string fieldName in fields) { int colIndex = reader.GetColIndex( fieldName ); int colType = reader.GetColType( colIndex ); // error is raised here on 2nd iteration } for ( int r = 0 ; r < reader.NumFields(); r++ ) { foreach(string fieldName in fields) { int colIndex = reader.GetColIndex( fieldName ); int colType = reader.GetColType( colIndex ); // error is raised here on 2nd iteration switch ( colType ) { case 0 : // INT processField( r, fieldName, reader.GetInt(r,colIndex) ); break ; .... } } } .... i've looked at interior_ptr, pin_ptr but they give an error c3160 cannot be in a managed class Any workaround ? BTW, this is my 1st C++ program in a very long time !

    Read the article

  • How do i prevent my code from being stolen?

    - by Calmarius
    What happens exactly when I launch a .NET exe? I know that C# is compiled to IL code and I think the generated exe file just a launcher that starts the runtime and passes the IL code to it. But how? And how complex process is it? IL code is embedded in the exe. I think it can be executed from the memory without writing it to the disk while ordinary exe's are not (ok, yes but it is very complicated). My final aim is extracting the IL code and write my own encrypted launcher to prevent scriptkiddies to open my code in Reflector and just steal all my classes easily. Well I can't prevent reverse engineering completely. If they are able to inspect the memory and catch the moment when I'm passing the pure IL to the runtime then it won't matter if it is a .net exe or not, is it? I know there are several obfuscator tools but I don't want to mess up the IL code itself. EDIT: so it seems it isn't worth trying what I wanted. They will crack it anyway... So I will look for an obfuscation tool. And yes my friends said too that it is enough to rename all symbols to a meaningless name. And reverse engineering won't be so easy after all.

    Read the article

  • Web services or shared database for (game) server communication?

    - by jaaronfarr
    We have 2 server clusters: the first is made up of typical web applications backed by SQL databases. The second are highly optimized multiplayer game servers which keep all data in memory. Both clusters communicate with clients via HTTP (Ajax with JSON). There are a few cases in which we need to share data between the two server types, for example, reporting back and storing the results of a game (should ultimately end up in the database). We're considering several approaches for inter-server communication: Just share the MySQL databases between clusters (introduce SQL to the game servers) Sharing data in a distributed key-value store like Memcache, Redis, etc. Use an RPC technology like Google ProtoBufs or Apache Thrift Using RESTful web services (the game server would POST back to the web servers, for example) At the moment, we're leaning towards web services or just sharing the database. Sharing the database seems easy, but we're concerned this adds extra memory and a new dependency into the game servers. Web services provide good separation of concerns and fit with the existing Ajax we use, but add complexity, overhead and many more ways for communication to fail. Are there any other good reasons not to use one or the other approach? Which would be easier to scale?

    Read the article

  • Delete on a very deep tree

    - by Kathoz
    I am building a suffix trie (unfortunately, no time to properly implement a suffix tree) for a 10 character set. The strings I wish to parse are going to be rather long (up to 1M characters). The tree is constructed without any problems, however, I run into some when I try to free the memory after being done with it. In particularly, if I set up my constructor and destructor to be as such (where CNode.child is a pointer to an array of 10 pointers to other CNodes, and count is a simple unsigned int): CNode::CNode(){ count = 0; child = new CNode* [10]; memset(child, 0, sizeof(CNode*) * 10); } CNode::~CNode(){ for (int i=0; i<10; i++) delete child[i]; } I get a stack overflow when trying to delete the root node. I might be wrong, but I am fairly certain that this is due to too many destructor calls (each destructor calls up to 10 other destructors). I know this is suboptimal both space, and time-wise, however, this is supposed to be a quick-and-dirty solution to a the repeated substring problem. tl;dr: how would one go about freeing the memory occupied by a very deep tree? Thank you for your time.

    Read the article

  • php | Multidimensional array sorting

    - by user889349
    I have an array and need to be sorted (based on id): Array ( [0] => Array ( [qty] => 1 [id] => 3 [name] => Name1 [sku] => Model 1 [options] => [price] => 100.00 ) [1] => Array ( [qty] => 2 [id] => 1 [name] => Name2 [sku] => Model 1 [options] => Color: <em>Black (+10$)</em>. Memory: <em>32GB (+99$)</em>. [price] => 209.00 ) ) Is it possible to sort my array to get output (id based)? Array ( [0] => Array ( [qty] => 2 [id] => 1 [name] => Name2 [sku] => Model 1 [options] => Color: <em>Black (+10$)</em>. Memory: <em>32GB (+99$)</em>. [price] => 209.00 ) [1] => Array ( [qty] => 1 [id] => 3 [name] => Name1 [sku] => Model 1 [options] => [price] => 100.00 ) ) Thanks!

    Read the article

  • Lazy load images in UITableViewCell

    - by lostInTransit
    Hi I have some 50 custom cells in my UITableView. I want to display an image and a label in the cells where I get the images from URLs. I want to do a lazy load of images so the UI does not freeze up while the images are being loaded. I tried getting the images in separate threads but I have to load each image every time a cell becomes visible again (Otherwise reuse of cells shows old images) Apps like Facebook load images only for cells currently visible and once the images are loaded, they are not loaded again. Can someone please tell me how to duplicate this behavior. Thanks. Edit Trying to cache images in an NSMutableDictionary object creates problems when the user scrolls fast. I am getting images only when scrolling completely stops and clearing out the cache on memory warning. But the app invariably gets a memory warning (due to size of images being cached) and clears the cache before reloading. If scrolling is very fast, it crashes. Any other suggestions are welcome

    Read the article

  • Is there a way to capture a bitmap from a WPF window using native C++?

    - by Mike Caron
    Imagine a document window in a MDI application which contains a child WPF window, say a sidebar for example. How can one get a bitmap containing both the WPF pixels AND the GDI (non-wpf) pixels? I've discovered that when making my thumbnail preview for the Win7 taskbar app icon hover, I get black in the parts of the preview where the WPF pixels should be. My current method simply grabs a bitmap capture of the document window. Then I get a DC for the preview, make a memory DC from it and select my bitmap into it. Then I do some size adjustments and bitblt the memory dc to the real dc. I'm guessing that the BitBlt operation doesn't take into account the fact that the WPF pixels are hardware accelerated and therefore need to be grabbed from the graphics hardware. All the stuff in GDI is managed just fine, though and when there's no WPF child windows, the preview image looks fine. I'm wondering if it's at all possible to grab a bitmap of the WPF window from native C++. Then I can blt that onto the black area of the previous preview.

    Read the article

  • Error while sending image through ajax to WCF

    - by Samar Rizvi
    Here is my form: <form id="register" enctype="multipart/form-data"> <input type="text" name="first_name" placeholder="First Name" id="first_name" /> <input type="text" name="last_name" placeholder="Last Name" id="last_name" /> <input type="text" name="input_email" placeholder="Confirm your email" id="input_email" class="loginEmail" /> <input type="password" name="input_password" placeholder="Password" id="input_password" class="loginPassword" /> <input type="password" name="repeat_password" placeholder="Repeat password" id="repeat_password" class="loginPassword" /> <input type="file" name="image_file" id="image_file" /> <div class="logControl"> <div class="memory"></div> <input type="submit" name="submit" value="Register" class="buttonM bBlue" id="register_submit"/> <div class="clear"></div> </div> <p><h3>Or click <a href="login.html">here</a> to login</h3></p> </form> Here is jquery call that I make: function WCFJSON() { $(".memory").html('<img src="images/elements/loaders/7s.gif" />'); Data = new FormData($('form')[0]); $.ajax({ type: 'POST', //GET or POST or PUT or DELETE verb url: "WCFService/Service.svc/Register", // Location of the service data: Data, //Data sent to server async:false, cache:false, contentType: false, // content type sent to server dataType: DataType, //Expected data format from server processdata: false, //True or False success: function(msg) {//On Successfull service call ... }, error: ...// When Service call fails }); } $(document).ready(function(){ $("#register").submit(function(){ $('#input_password').val(CryptoJS.MD5($('#input_password').val())); $('#repeat_password').val(CryptoJS.MD5($('#repeat_password').val())); WCFJSON(); return false; }); }); Now when I submit the form , page refreshes with get elements in the url. But if I remove the file input from the form, jquery works fine.

    Read the article

  • Why does reusing arrays increase performance so significantly in c#?

    - by Willem
    In my code, I perform a large number of tasks, each requiring a large array of memory to temporarily store data. I have about 500 tasks. At the beginning of each task, I allocate memory for an array : double[] tempDoubleArray = new double[M]; M is a large number depending on the precise task, typically around 2000000. Now, I do some complex calculations to fill the array, and in the end I use the array to determine the result of this task. After that, the tempDoubleArray goes out of scope. Profiling reveals that the calls to construct the arrays are time consuming. So, I decide to try and reuse the array, by making it static and reusing it. It requires some additional juggling to figure out the minimum size of the array, requiring an extra pass through all tasks, but it works. Now, the program is much faster (from 80 sec to 22 sec for execution of all tasks). double[] tempDoubleArray = staticDoubleArray; However, I'm a bit in the dark of why precisely this works so well. Id say that in the original code, when the tempDoubleArray goes out of scope, it can be collected, so allocating a new array should not be that hard right? I ask this because understanding why it works might help me figuring out other ways to achieve the same effect, and because I would like to know in what cases allocation gives performance issues.

    Read the article

  • Why doesn't Firefox redownload images already on a page?

    - by vvo
    Hello, i just read this article : https://developer.mozilla.org/en/HTTP_Caching_FAQ There's a firefox behavior (and some other browsers i guess) i'd like to understand : if i take any webpage and try to insert the same image multiple times in javascript, the image is only downloaded ONCE even if i specifiy all needed headers to say "do no ever use cache". (see article) I know there are workarounds (like addind query strings to end of urls etc) but why do firefox act like that, if i say that an image do not have to be cached, why is the image still taken from cache when i try to re-insert it ? Plus, what cache is used for this ? (I guess it's the memory cache) Is this behavior the same for dynamic inclusion for example ? ANSWSER IS NO :) I just tested it and the same headers for a js script will make firefox redownload it each time you append the script to the DOM. PS: I know you're wondering WHY i need to do that (appending same image multiple times and force to redownload but this is the way our app works) thank you The good answer is : firefox will store images for the current page load in the memory cache even if you specify he doesnt have to cache them. You can't change this behavior but this is odd because it's not the same for javascript files for example Could someone explain or link to a document describing how firefox cache WORKS?

    Read the article

  • What could the negative effects be of attaching to a process as a debugger?

    - by I_like_traffic_lights
    Background A client of mine has a major problem. They have a CRM system, which was created by a single person over a period of 9 years. Unfortunatelly, a few weeks ago, this person died. I believe the company has learned their lesson, and they have started a project of rewriting the CRM system to a modern platform. I have been hired to create a solution in the meantime to make adaptations to the CRM system. I have given up understanding the code, as this would take too long. My solution, is therefore, to make a window and show this on top of the CRM system, whenever this CRM system is showing. This part works fine, but my major problem is extracting the data from the CRM system. Proposed solution After excluding 6 approaches, including runtime code injection, memory searching, database integration, I have arrived at attaching to the process as a debugger, so I get notified about event, and use this in combination with reading from process memory. This approach seems to work, but I am worried about possible side-effects of this approach. Question What are the dangers of using this in a production environment, where there are 250 employees utilizing the system. Needless to say, I cannot risk reducing the already shaky stability of the system.

    Read the article

  • Is a web-server (e.g servlets) a good solution for an IM server?

    - by John
    I'm looking at a new app, broadly speaking an IM application with a strong client-server model - all communications go through a server so they can be logged centrally. The server will be Java in some form, clients could at this point be anything from a .NET Desktop app to Flex/Silverlight, to a simple web-interface using JS/AJAX. I had anticipated doing the server using standard J2EE so I get a thread-safe, multi-user server for 'free'... to make things simple let's say using Servlets (but in practice SpringMVC would be likely). This all seemed very neat but I'm concerned if the stateless nature of Servlets is the best approach. If my memory of servlets (been a year or two) is right, each time a client sent a HTTP request, typically a new message entered by the user, the servlet could not assume it had the user/chat in memory and might have to get it from the DB... regardless it has to look it up. Then it either has to use some PUSH system to inform other members of the chat, or cache that there are new messages, for other clients who poll the server using AJAX or similar - and when they poll it again has to lookup the chat, including new messages, and send the new data. I'm wondering if a better system would be the server is running core Java, and implements a socket-based communication with clients. This allows much more immediate data transfer and is more flexible if say the IM client included some game you could play. But then you're writing a custom server and sockets don't sound very friendly to a browser-based client on current browsers. Am I missing some big piece of the puzzle here, it kind of feels like I am? Perhaps a better way to ask the question would simply be "if the client was browser-based using HTML/JS and had to run on IE7+,FF2+ (i.e no HTML5), how would you implement the server?" edit: if you are going to suggest using XMPP, I have been trying to get my head around this in another question, so please consider if that's a more appropriate place to discuss this specifically.

    Read the article

  • Android designing an app to keep me logged into a wifi access point

    - by MrGibbage
    At the gym where I work out, they have an open wifi access point. The way it is set up, once you "connect", you have to navigate to a web page (it is a 1.1.X.X ip address) and click the "I agree" button, after presumably reading the user agreement. The problem is, they have it set up to log you out once an hour, which always happens in the middle of my workout. I have the SSID remembered, so it connects automatically when I come in range, but I get an android notification that further action is needed to fully connect. What I was wondering is if there a work around so that I don't have to click-through every hour? I was thinking of writing an app that could detect when I was in range, or when "half-connected", and then have it somehow complete the registration process. Perhaps this will have to be done by loading the web page in memory and then somehow clicking the "I agree" button. What I would like help with is: 1) what is the terminology involved here? What state is the connection in when I am connected, but I haven't clicked through? What other connection states may apply? If I knew that, I might just be able to research this and come up with a solution. Are these different states "detectable"? It seems like it is since I get a notification that I need to complete the registration process when I am "half-connected". 2) I know there are plugins for desktop browsers that can click buttons (like the keepass plugins, which will log you into a site). How could I replicate this in Android? Ideally I would like to do it internally, in memory, rather than firing up a browser. Possible? Comments? Is my understanding and thought process sound here, or am I overlooking something?

    Read the article

  • How do I read hex numbers into an unsigned int in C [Solved]

    - by sil3nt
    I'm wanting to read hex numbers from a text file into an unsigned integer so that I can execute Machine instructions. It's just a simulation type thing that looks inside the text file and according to the values and its corresponding instruction outputs the new values in the registers. For example, the instructions would be: 1RXY - Save register R with value in memory address XY 2RXY - Save register R with value XY BRXY - Jump to register R if xy is this and that etc.. ARXY - AND register R with value at memory address XY The text file contains something like this each in a new line. (in hexidecimal) 120F B007 290B My problem is copying each individual instruction into an unsigned integer...how do I do this? #include <stdio.h> int main(){ FILE *f; unsigned int num[80]; f=fopen("values.txt","r"); if (f==NULL){ printf("file doesnt exist?!"); } int i=0; while (fscanf(f,"%x",num[i]) != EOF){ fscanf(f,"%x",num[i]); i++; } fclose(f); printf("%x",num[0]); }

    Read the article

  • !gcroot output leads nowhere

    - by Jeff Costa
    I am troubleshooting memory fragmentation in an app pool, as evidenced by a small number of Free objects consuming the most space on the heap: 0x000007ff00256728 6,543 3,890,208 System.Collections.Hashtable+bucket[] 0x000007ff002649a8 7,297 22,979,560 System.Byte[] 0x000007ff001e0d90 251,347 30,374,304 System.String 0x0000000001d0c830 373 48,036,816 Free Running the !dumpgen 3 command reveals the fragmentation; There is a repeating pattern of Free and System.Object objects of the same size: 000000017feb7350 24 **** FREE **** 000000017feb7368 8192 System.Object[] 000000017feb9368 24 **** FREE **** 000000017feb9380 8192 System.Object[] 000000017febb380 24 **** FREE **** 000000017febb398 8192 System.Object[] 000000017febd398 24 **** FREE **** 000000017febd3b0 8192 System.Object[] 000000017febf3b0 24 **** FREE **** 000000017febf3c8 8192 System.Object[] 000000017fec13c8 24 **** FREE **** 000000017fec13e0 8192 System.Object[] 000000017fec33e0 24 **** FREE **** 000000017fec33f8 8192 System.Object[] 000000017fec53f8 24 **** FREE **** 000000017fec5410 14024 System.Object[] 000000017fec8ad8 24 **** FREE **** 000000017fec8af0 8192 System.Object[] 000000017fecaaf0 24 **** FREE **** 000000017fecab08 8192 System.Object[] 000000017feccb08 24 **** FREE **** 000000017feccb20 8192 System.Object[] 000000017feceb20 24 **** FREE **** 000000017feceb38 8192 System.Object[] 000000017fed0b38 24 **** FREE **** 000000017fed0b50 8192 System.Object[] 000000017fed2b50 24 **** FREE **** 000000017fed2b68 8192 System.Object[] When I try to obtain the root of one of the System.Objects with !gcroot, I get a pinned handle, but no additional stack data: Scan Thread 41 OSThread 1044 DOMAIN(0000000001D51330):HANDLE(Pinned):15217e8:Root: 000000017fe60fe8(System.Object[]) As you can see, there is no additional data to go on. Running a !handle command also yields nothing: 0:041> !handle 000000017fe7a068 ff Handle 000000017fe7a068 Type <Error retrieving type> unable to query object information unable to query object information No object specific information available How can I trace out this memory leak when I cannot find what is rooting System.Object?

    Read the article

  • Sorting a very large text file in Java

    - by Alice
    Hi, I have a large text file I need to sort in Java. The format is: word [tab] frequency [new line] The algorithm for sorting is: Read some of the file, filtering for purlely alphabetic words. Once you have X number of alphabetic words, call Collections.sort and write the result to a file. Repeat until you have finished reading the file. Start reading two sorted files, comparing line by line for the word with higher frequency, and writing at the same time to a new file as to not load much into your memory Repeat until all files are merged into one large file Right now I've divided the large file into smaller ones (sorted by descending frequency) with 10,000 lines each. I know I need to somehow merge these files back together, but I'm not sure how to go about this. I've created a LinkedList to keep track of all the files created. The algorithm says to compare each line in the two files, except I've tried a case where , say file1 = 8,6,5,3,1 and file2 = 9,8,8,8,8. Then if I compare them line by line I would get file3 = 9,8,8,6,8,5,8,3,8,1 which is incorrectly sorted (they should be in decreasing order). I think I'm misunderstanding some part of the algorithm. If someone could point out what I should do instead, I'd greatly appreciate it. Thanks. edit: Yes this is an assignment. We aren't allowed to increase memory unfortunately :(

    Read the article

< Previous Page | 243 244 245 246 247 248 249 250 251 252 253 254  | Next Page >