Search Results

Search found 5346 results on 214 pages for 'register allocation'.

Page 1/214 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Automatic allocation(not Dynamic Allocation) on Windows DHCP server

    - by Kazoom
    DHCP supports three different mechanisms for IP address allocation: Manual allocation: the server's administrator creates a configuration for the server that includes the MAC address and IP address of each DHCP client that will be able to get an address: functionally equivalent to BOOTP though the protocol is incompatible. Automatic allocation: the server's administrator creates a configuration for the server that includes only IP addresses, which it gives out to clients. An IP address, once associated with a MAC address, is permanently associated with it until the server's administrator intervenes. Dynamic allocation: like automatic allocation except that the server will track leases and give IP addresses whose lease has expired to other DHCP clients How can i configure the automatic allocation on Windows 2000 or XP DHCP server? i can think of setting the lease to unlimited period, but i m not sure if the computer shutsdown gracefully it will make the ip address available to other machine.

    Read the article

  • Simple dynamic memory allocation bug.

    - by M4design
    I'm sure you (pros) can identify the bug's' in my code, I also would appreciate any other comments on my code. BTW, the code crashes after I run it. #include <stdlib.h> #include <stdio.h> #include <stdbool.h> typedef struct { int x; int y; } Location; typedef struct { bool walkable; unsigned char walked; // number of times walked upon } Cell; typedef struct { char name[40]; // Name of maze Cell **grid; // 2D array of cells int rows; // Number of rows int cols; // Number of columns Location entrance; } Maze; Maze *maz_new() { int i = 0; Maze *mazPtr = (Maze *)malloc(sizeof (Maze)); if(!mazPtr) { puts("The memory couldn't be initilised, Press ENTER to exit"); getchar(); exit(-1); } else { // allocating memory for the grid mazPtr->grid = (Cell **) malloc((sizeof (Cell)) * (mazPtr->rows)); for(i = 0; i < mazPtr->rows; i++) mazPtr->grid[i] = (Cell *) malloc((sizeof (Cell)) * (mazPtr->cols)); } return mazPtr; } void maz_delete(Maze *maz) { int i = 0; if (maz != NULL) { for(i = 0; i < maz->rows; i++) free(maz->grid[i]); free(maz->grid); } } int main() { Maze *ptr = maz_new(); maz_delete(ptr); getchar(); return 0; } Thanks in advance.

    Read the article

  • Segment register, IP register and memory addressing issue!

    - by Zia ur Rahman
    In the following text I asked two questions and I also described that what I know about these question so that you can understand my thinking. Your precious comments about the below text are required. Below is the Detail of 1ST Question As we know that if we have one mega byte memory then we need 20 bits to address this memory. Another thing is each memory cell has a physical address which is of 20 bits in 1Mb memory. IP register in IAPX88 is of 16 bits. Now my point of view is, we can not access the memory at all by the IP register because the memory need 20 bit address to be addressed but the IP register is of 16 bits. If we have a memory of 64k then IP register can access this memory because this memory needs 16 bits to be addressed. But incase of 1mb memory IP can’t.tell me am i right or not if not why? Suppose physical address of memory is 11000000000000000101 Now how can we access this memory location by 16 bits. Below is the detail of Next Question: My next question is , suppose IP register is pointing to memory location, and the segment register is also pointing to a memory location (start of the segment), the memory is of 1MB, how we can access a memory location by these two 16 bit registers tell me the sequence of steps how the 20 bits addressable memory location is accessed . If your answer is, we take the segment value and we shift it left by 4 bits and then add the IP value into it to get the 20 bits address, then this raises another question that is the address bus (the address bus should be 20 bits wide), the registers both the segment register and the IP register are of 16 bits each , now if address bus is 20 bits wide then this means that the address bus is connected to both these registers. If its not the case then another thing that comes into my mind is that both these registers generate a 20 bit address and there would be a register which can store 20 bits and this register would be connected to both these register and the address bus as well.

    Read the article

  • what appropriate "Allocation Unit Size" for an exFAT SD card with ReadyBoost

    - by Revolter
    I've brought an 4GB SD card and I'm dedicating it for use by ReadyBoost (on Windows7) Im looking to get the most profit on performance, so i've formatted it with exFAT (as recommended by Microsoft) but I have some doubts to define what best .Allocation Unit Size* I should choose. Since I can't get how ReadyBoost/SD card exactly read/seek the data, can someone tell what make choosing an Allocation Unit Size in favor of another for this scheme ? Apparently, ReadyBoost is allocating all the free space in SD card as one huge file, so a big Allocation Unit Size is advised for fastest reading time. I'm not confusing with ordinary HDD's ?

    Read the article

  • Cant register this user

    - by holgero
    I wanted to ask this question on meta, but it said, I have to log in first (which is where I have the problem!) I answered a question with this user. But when I tried to register and click on the stack exchange icon, it only displays three dots (animated) and never comes back. I suspected a firefox problem so I tried firefox on windows: And yes, I was able to create an account linked with my other accounts ( http://unix.stackexchange.com/users/27867/holgero and http://stackoverflow.com/users/1779245/holgero ) when I ran the latest firefox version under windows 7 in a virtual box. Then I upgraded my linux firefox to the newest version and deleted the other account under windows again. But still I cannot register this account ( http://superuser.com/users/177338/holgero ). On unix.stackexchange or stackoverflow I never had any problems with the registration, superuser seems to be different. So, how do I register this user and have it linked with my other stackexchange accounts?

    Read the article

  • SYSTEM hive of the register is causing computer to BSOD on boot

    - by FernandoSBS
    After some work on my computer, perhaps some updates installs, it didn't boot anymore. BSOD on windows logo loading. After some research I've found out that if I replace the SYSTEM hive of the register with the last backup it boots ok, but of course goes back to an old stage of machine setup. So my question is: where does register stores hardware and/or updates/software that loads in the machine boot, so that I can check which program is producing that BSOD and disable it? System is Win 7 64 bits SP1

    Read the article

  • Valgrind says "stack allocation," I say "heap allocation"

    - by Joel J. Adamson
    Dear Friends, I am trying to trace a segfault with valgrind. I get the following message from valgrind: ==3683== Conditional jump or move depends on uninitialised value(s) ==3683== at 0x4C277C5: sparse_mat_mat_kron (sparse.c:165) ==3683== by 0x4C2706E: rec_mating (rec.c:176) ==3683== by 0x401C1C: age_dep_iterate (age_dep.c:287) ==3683== by 0x4014CB: main (age_dep.c:92) ==3683== Uninitialised value was created by a stack allocation ==3683== at 0x401848: age_dep_init_params (age_dep.c:131) ==3683== ==3683== Conditional jump or move depends on uninitialised value(s) ==3683== at 0x4C277C7: sparse_mat_mat_kron (sparse.c:165) ==3683== by 0x4C2706E: rec_mating (rec.c:176) ==3683== by 0x401C1C: age_dep_iterate (age_dep.c:287) ==3683== by 0x4014CB: main (age_dep.c:92) ==3683== Uninitialised value was created by a stack allocation ==3683== at 0x401848: age_dep_init_params (age_dep.c:131) However, here's the offending line: /* allocate mating table */ age_dep_data->mtable = malloc (age_dep_data->geno * sizeof (double *)); if (age_dep_data->mtable == NULL) error (ENOMEM, ENOMEM, nullmsg, __LINE__); for (int j = 0; j < age_dep_data->geno; j++) { 131=> age_dep_data->mtable[j] = calloc (age_dep_data->geno, sizeof (double)); if (age_dep_data->mtable[j] == NULL) error (ENOMEM, ENOMEM, nullmsg, __LINE__); } What gives? I thought any call to malloc or calloc allocated heap space; there is no other variable allocated here, right? Is it possible there's another allocation going on (the offending stack allocation) that I'm not seeing? You asked to see the code, here goes: /* Copyright 2010 Joel J. Adamson <[email protected]> $Id: age_dep.c 1010 2010-04-21 19:19:16Z joel $ age_dep.c:main file Joel J. Adamson -- http://www.unc.edu/~adamsonj Servedio Lab University of North Carolina at Chapel Hill CB #3280, Coker Hall Chapel Hill, NC 27599-3280 This file is part of an investigation of age-dependent sexual selection. This code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with haploid. If not, see <http://www.gnu.org/licenses/>. */ #include "age_dep.h" /* global variables */ extern struct argp age_dep_argp; /* global error message variables */ char * nullmsg = "Null pointer: %i"; /* error message for conversions: */ char * errmsg = "Representation error: %s"; /* precision for formatted output: */ const char prec[] = "%-#9.8f "; const size_t age_max = AGEMAX; /* maximum age of males */ static int keep_going_p = 1; int main (int argc, char ** argv) { /* often used counters: */ int i, j; /* read the command line */ struct age_dep_args age_dep_args = { NULL, NULL, NULL }; argp_parse (&age_dep_argp, argc, argv, 0, 0, &age_dep_args); /* set the parameters here: */ /* initialize an age_dep_params structure, set the members */ age_dep_params_t * params = malloc (sizeof (age_dep_params_t)); if (params == NULL) error (ENOMEM, ENOMEM, nullmsg, __LINE__); age_dep_init_params (params, &age_dep_args); /* initialize frequencies: this initializes a list of pointers to initial frqeuencies, terminated by a NULL pointer*/ params->freqs = age_dep_init (&age_dep_args); params->by = 0.0; /* what range of parameters do we want, and with what stepsize? */ /* we should go from 0 to half-of-theta with a step size of about 0.01 */ double from = 0.0; double to = params->theta / 2.0; double stepsz = 0.01; /* did you think I would spell the whole word? */ unsigned int numparts = floor(to / stepsz); do { #pragma omp parallel for private(i) firstprivate(params) \ shared(stepsz, numparts) for (i = 0; i < numparts; i++) { params->by = i * stepsz; int tries = 0; while (keep_going_p) { /* each time through, modify mfreqs and mating table, then go again */ keep_going_p = age_dep_iterate (params, ++tries); if (keep_going_p == ERANGE) error (ERANGE, ERANGE, "Failure to converge\n"); } fprintf (stdout, "%i iterations\n", tries); } /* for i < numparts */ params->freqs = params->freqs->next; } while (params->freqs->next != NULL); return 0; } inline double age_dep_pmate (double age_dep_t, unsigned int genot, double bp, double ba) { /* the probability of mating between these phenotypes */ /* the female preference depends on whether the female has the preference allele, the strength of preference (parameter bp) and the male phenotype (age_dep_t); if the female lacks the preference allele, then this will return 0, which is not quite accurate; it should return 1 */ return bits_isset (genot, CLOCI)? 1.0 - exp (-bp * age_dep_t) + ba: 1.0; } inline double age_dep_trait (int age, unsigned int genot, double by) { /* return the male trait, a function of the trait locus, age, the age-dependent scaling parameter (bx) and the males condition genotype */ double C; double T; /* get the male's condition genotype */ C = (double) bits_popcount (bits_extract (0, CLOCI, genot)); /* get his trait genotype */ T = bits_isset (genot, CLOCI + 1)? 1.0: 0.0; /* return the trait value */ return T * by * exp (age * C); } int age_dep_iterate (age_dep_params_t * data, unsigned int tries) { /* main driver routine */ /* number of bytes for female frequencies */ size_t geno = data->age_dep_data->geno; size_t genosize = geno * sizeof (double); /* female frequencies are equal to male frequencies at birth (before selection) */ double ffreqs[geno]; if (ffreqs == NULL) error (ENOMEM, ENOMEM, nullmsg, __LINE__); /* do not set! Use memcpy (we need to alter male frequencies (selection) without altering female frequencies) */ memmove (ffreqs, data->freqs->freqs[0], genosize); /* for (int i = 0; i < geno; i++) */ /* ffreqs[i] = data->freqs->freqs[0][i]; */ #ifdef PRMTABLE age_dep_pr_mfreqs (data); #endif /* PRMTABLE */ /* natural selection: */ age_dep_ns (data); /* normalized mating table with new frequencies */ age_dep_norm_mtable (ffreqs, data); #ifdef PRMTABLE age_dep_pr_mtable (data); #endif /* PRMTABLE */ double * newfreqs; /* mutate here */ /* i.e. get the new frequency of 0-year-olds using recombination; */ newfreqs = rec_mating (data->age_dep_data); /* return block */ { if (sim_stop_ck (data->freqs->freqs[0], newfreqs, GENO, TOL) == 0) { /* if we have converged, stop the iterations and handle the data */ age_dep_sim_out (data, stdout); return 0; } else if (tries > MAXTRIES) return ERANGE; else { /* advance generations */ for (int j = age_max - 1; j < 0; j--) memmove (data->freqs->freqs[j], data->freqs->freqs[j-1], genosize); /* advance the first age-class */ memmove (data->freqs->freqs[0], newfreqs, genosize); return 1; } } } void age_dep_ns (age_dep_params_t * data) { /* calculate the new frequency of genotypes given additive fitness and selection coefficient s */ size_t geno = data->age_dep_data->geno; double w[geno]; double wbar, dtheta, ttheta, dcond, tcond; double t, cond; /* fitness parameters */ double mu, nu; mu = data->wparams[0]; nu = data->wparams[1]; /* calculate fitness */ for (int j = 0; j < age_max; j++) { int i; for (i = 0; i < geno; i++) { /* calculate male trait: */ t = age_dep_trait(j, i, data->by); /* calculate condition: */ cond = (double) bits_popcount (bits_extract(0, CLOCI, i)); /* trait-based fitness term */ dtheta = data->theta - t; ttheta = (dtheta * dtheta) / (2.0 * nu * nu); /* condition-based fitness term */ dcond = CLOCI - cond; tcond = (dcond * dcond) / (2.0 * mu * mu); /* calculate male fitness */ w[i] = 1 + exp(-tcond) - exp(-ttheta); } /* calculate mean fitness */ /* as long as we calculate wbar before altering any values of freqs[], we're safe */ wbar = gen_mean (data->freqs->freqs[j], w, geno); for (i = 0; i < geno; i++) data->freqs->freqs[j][i] = (data->freqs->freqs[j][i] * w[i]) / wbar; } } void age_dep_norm_mtable (double * ffreqs, age_dep_params_t * params) { /* this function produces a single mating table that forms the input for recombination () */ /* i is female genotype; j is male genotype; k is male age */ int i,j,k; double norm_denom; double trait; size_t geno = params->age_dep_data->geno; for (i = 0; i < geno; i++) { double norm_mtable[geno]; /* initialize the denominator: */ norm_denom = 0.0; /* find the probability of mating and add it to the denominator */ for (j = 0; j < geno; j++) { /* initialize entry: */ norm_mtable[j] = 0.0; for (k = 0; k < age_max; k++) { trait = age_dep_trait (k, j, params->by); norm_mtable[j] += age_dep_pmate (trait, i, params->bp, params->ba) * (params->freqs->freqs)[k][j]; } norm_denom += norm_mtable[j]; } /* now calculate entry (i,j) */ for (j = 0; j < geno; j++) params->age_dep_data->mtable[i][j] = (ffreqs[i] * norm_mtable[j]) / norm_denom; } } My current suspicion is the array newfreqs: I can't memmove, memcpy or assign a stack variable then hope it will persist, can I? rec_mating() returns double *.

    Read the article

  • efficacy of register allocation algorithms!

    - by aksci
    i'm trying to do a research/project on register allocation using graph coloring where i am to test the efficiency of different optimizing register allocation algorithms in different scenarios. how do i start? what are the prerequisites and the grounds with which i can test them. what all algos can i use? thank you!

    Read the article

  • java - register problem

    - by Jake
    Hi! When i try to register a person with the name Eric for example, and then again registrating Eric it works. This should not happen with the code i have. Eric should not be registrated if theres already an Eric in the list. Here is my full code: import java.util.*; import se.lth.cs.pt.io.*; class Person { private String name; private String nbr; public Person (String name, String nbr) { this.name = name; this.nbr = nbr; } public String getName() { return name; } public String getNumber() { return nbr; } public String toString() { return name + " : " + nbr; } } class Register { private List<Person> personer; public Register() { personer = new ArrayList<Person>(); } // boolean remove(String name) { // } private Person findName(String name) { for (Person person : personer) { if (person.getName() == name) { return person; } } return null; } private boolean containsName(String name) { return findName(name) != null; } public boolean insert(String name, String nbr) { if (containsName(name)) { return false; } Person person = new Person(name, nbr); personer.add(person); Collections.sort(personer, new A()); return true; } //List<Person> findByPartOfName(String partOfName) { //} //List<Person> findByNumber(String nbr) { //} public List<Person> findAll() { List<Person> copy = new ArrayList<Person>(); for (Person person : personer) { copy.add(person); } return copy; } public void printList(List<Person> personer) { for (Person person : personer) { System.out.println(person.toString()); } } } class A implements Comparator < Person > { @Override public int compare(Person o1, Person o2) { if(o1.getName() != null && o2.getName() != null){ return o1.getName().compareTo(o2.getName()); } return 0; } } class TestScript { public static void main(String[] args) { new TestScript().run(); } void test(String msg, boolean status) { if (status) { System.out.println(msg + " -- ok"); } else { System.out.printf("==== FEL: %s ====\n", msg); } } void run() { Register register = new Register(); System.out.println("Vad vill du göra:"); System.out.println("1. Lägg in ny person."); System.out.println("2. Tag bort person."); System.out.println("3. Sök på del av namn."); System.out.println("4. Se vem som har givet nummer."); System.out.println("5. Skriv ut alla personer."); System.out.println("0. Avsluta."); int cmd = Keyboard.nextInt("Ange kommando (0-5): "); if (cmd == 0 ) { } else if (cmd == 1) { String name = Keyboard.nextLine("Namn: "); String nbr = Keyboard.nextLine("Nummer: "); System.out.println("\n"); String inlagd = "OK - " + name + " är nu inlagd."; String ejinlagd = name + " är redan inlagd."; test("Skapar nytt konto", register.insert(name, nbr) == true); System.out.println("\n"); } else if (cmd == 2) { } else if (cmd == 3) { } else if (cmd == 4) { } else if (cmd == 5) { System.out.println("\n"); register.printList(register.findAll()); System.out.println("\n"); } else { System.out.println("Inget giltigt kommando!"); System.out.println("\n"); } } }

    Read the article

  • Allocation algorithm help, using Python.

    - by Az
    Hi there, I've been working on this general allocation algorithm for students. The pseudocode for it (a Python implementation) is: for a student in a dictionary of students: for student's preference in a set of preferences (ordered from 1 to 10): let temp_project be the first preferred project check if temp_project is available if so, allocate it to them and make the project UNavailable to others Quite simply this will try to allocate projects by starting from their most preferred. The way it works, out of a set of say 100 projects, you list 10 you would want to do. So the 10th project wouldn't be the "least preferred overall" but rather the least preferred in their chosen set, which isn't so bad. Obviously if it can't allocate a project, a student just reverts to the base case which is an allocation of None, with a rank of 11. What I'm doing is calculating the allocation "quality" based on a weighted sum of the ranks. So the lower the numbers (i.e. more highly preferred projects), the better the allocation quality (i.e. more students have highly preferred projects). That's basically what I've currently got. Simple and it works. Now I'm working on this algorithm that tries to minimise the allocation weight locally (this pseudocode is a bit messy, sorry). The only reason this will probably work is because my "search space" as it is, isn't particularly large (just a very general, anecdotal observation, mind you). Since the project is only specific to my Department, we have their own limits imposed. So the number of students can't exceed 100 and the number of preferences won't exceed 10. for student in a dictionary/list/whatever of students: where i = 0 take the (i)st student, (i+1)nd student for their ranks: allocate the projects and set local_weighting to be sum(student_i.alloc_proj_rank, student_i+1.alloc_proj_rank) these are the cases: if local_weighting is 2 (i.e. both ranks are 1): then i += 1 and and continue above if local weighting is = N>2 (i.e. one or more ranks are greater than 1): let temp_local_weighting be N: pick student with lowest rank and then move him to his next rank and pick the other student and reallocate his project after this if temp_local_weighting is < N: then allocate those projects to the students move student with lowest rank to the next rank and reallocate other if temp_local_weighting < previous_temp_allocation: let these be the new allocated projects try moving for the lowest rank and reallocate other else: if this weighting => previous_weighting let these be the allocated projects i += 1 and move on for the rest of the students So, questions: This is sort of a modification of simulated annealing, but any sort of comments on this would be appreciated. How would I keep track of which student is (i) and which student is (i+1) If my overall list of students is 100, then the thing would mess up on (i+1) = 101 since there is none. How can I circumvent that? Any immediate flaws that can be spotted? Extra info: My students dictionary is designed as such: students[student_id] = Student(student_id, student_name, alloc_proj, alloc_proj_rank, preferences) where preferences is in the form of a dictionary such that preferences[rank] = {project_id}

    Read the article

  • PhP Login/Register system [migrated]

    - by Marian
    I found this good tutorial on creating a login/register system using PhP and MySQL. The forum is around 5 years old (edited last year) but it can still be usefull. Beginner Simple Register-Login system There seems to be an issue with both login and register pages. <?php function register_form(){ $date = date('D, M, Y'); echo "<form action='?act=register' method='post'>" ."Username: <input type='text' name='username' size='30'><br>" ."Password: <input type='password' name='password' size='30'><br>" ."Confirm your password: <input type='password' name='password_conf' size='30'><br>" ."Email: <input type='text' name='email' size='30'><br>" ."<input type='hidden' name='date' value='$date'>" ."<input type='submit' value='Register'>" ."</form>"; } function register(){ $connect = mysql_connect("host", "username", "password"); if(!$connect){ die(mysql_error()); } $select_db = mysql_select_db("database", $connect); if(!$select_db){ die(mysql_error()); } $username = $_REQUEST['username']; $password = $_REQUEST['password']; $pass_conf = $_REQUEST['password_conf']; $email = $_REQUEST['email']; $date = $_REQUEST['date']; if(empty($username)){ die("Please enter your username!<br>"); } if(empty($password)){ die("Please enter your password!<br>"); } if(empty($pass_conf)){ die("Please confirm your password!<br>"); } if(empty($email)){ die("Please enter your email!"); } $user_check = mysql_query("SELECT username FROM users WHERE username='$username'"); $do_user_check = mysql_num_rows($user_check); $email_check = mysql_query("SELECT email FROM users WHERE email='$email'"); $do_email_check = mysql_num_rows($email_check); if($do_user_check > 0){ die("Username is already in use!<br>"); } if($do_email_check > 0){ die("Email is already in use!"); } if($password != $pass_conf){ die("Passwords don't match!"); } $insert = mysql_query("INSERT INTO users (username, password, email) VALUES ('$username', '$password', '$email')"); if(!$insert){ die("There's little problem: ".mysql_error()); } echo $username.", you are now registered. Thank you!<br><a href=login.php>Login</a> | <a href=index.php>Index</a>"; } switch($act){ default; register_form(); break; case "register"; register(); break; } ?> Once pressed the register button the page does nothing, fields are erased and no data is added inside the database or error given. I tought that the problem might be the switch($act){ part so I removed it and changed the page using a require require('connect.php'); where connect.php is <?php mysql_connect("localhost","host","password"); mysql_select_db("database"); ?> Removed the function register_form(){ and echo part turning it into an HTML code: <form action='register' method='post'> Username: <input type='text' name='username' size='30'><br> Password: <input type='password' name='password' size='30'><br> Confirm your password: <input type='password' name='password_conf' size='30'><br> Email: <input type='text' name='email' size='30'><br> <input type='hidden' name='date' value='$date'> <input type='submit' name="register" value='Register'> </form> And instead of having a function register(){ I replaced it with a if($register){ So when the Register button is pressed it runs the php code, but this edit doesn't seem to work either. So what can the problem be? If needed I can re-add this code on my Domain The login page has the same issue, nothing happens when the button is pressed beside emptying the fields.

    Read the article

  • Memory Allocation increases in didSelectRowAtIndexPath

    - by mongeta
    Hello, I'm testing my App and in a very simple view, each time a tap on a UITableView row, my allocation overall bytes get higher and higher and never go downs. I don't have any special code there, so I created a new project from scratch with a very simple view, force one section and just three rows. In the didSelectRowAtIndexPath code do nothing, and fire it with instruments and memory allocation and, the memory goes up with every cell selection ... Is this normal behaviour ? thanks, regards, m.

    Read the article

  • How do I mock memory allocation failures ?

    - by Andrei Ciobanu
    I want to extensively test some pieces of C code for memory leaks. On my machine I have 4 Gb of RAM, so it's very unlikely for a dynamic memory allocation to fail. Still I want to see the comportment of the code if memory allocation fails, and see if the recover mechanism is "strong" enough. What do you suggest ? How do I emulate an environment with lower memory specs ? How do i mock my tests ? EDIT: I want my tests to be code independent. I only have "access" to return values for different functions in the library I am testing. I am not supposed to write "test logic" inside the code I am testing.

    Read the article

  • Bad allocation exceptions in C++

    - by me1982
    Hello, In a school project of mine I was requested to create a program not using STL. In the program I use alot of Pointer* = new Something; if (Pointer == NULL) throw AllocationError(); My question is about allocation errors: 1. is there an autamtic exception thrown by new when allocation fails? 2. if so how can I catch it if I'm not using STL (#include "exception.h) 3. is using the NULL testing enugh? thank you. I'm using eclipseCDT(C++) with MinGW on windows 7.

    Read the article

  • some register.inclusion_tag error in my code using django

    - by zjm1126
    my helloworld_tags: from django import template register = template.Library() def show_profile(): return {"eee": '333'} register.inclusion_tag("b.html")(show_profile) my view: def b(request): return render_to_response('b.html') my html: {% load helloworld_tags%} dsad {{ eee }} but only show 'dsad' ,not show 'dsad333' why?? thanks

    Read the article

  • dynamic memory allocation in C

    - by avanish
    int main() { int p; scanf("%d",&p); fun() { int arr[p]; //isn't this similar to dynamic memory allocation?? } } //if not then what other objective is achieved using malloc and calloc?? //Someone please throw some light :-)

    Read the article

  • Memory allocation problem C/Cpp Windows critical error

    - by Andrew
    Hi! I have a code that need to be "translated" from C to Cpp, and i cant understand, where's a problem. There is the part, where it crashes (windows critical error send/dontSend): nDim = sizeMax*(sizeMax+1)/2; printf("nDim = %d sizeMax = %d\n",nDim,sizeMax); hamilt = (double*)malloc(nDim*sizeof(double)); printf("End hamilt alloc. %d allocated\n",(nDim*sizeof(double))); transProb = (double*)malloc(sizeMax*sizeMax*sizeof(double)); printf("End transProb alloc. %d allocated\n",(sizeMax*sizeMax*sizeof(double))); eValues = (double*)malloc(sizeMax*sizeof(double)); printf("eValues allocated. %d allocated\n",(sizeMax*sizeof(double))); eVectors = (double**)malloc(sizeMax*sizeof(double*)); printf("eVectors allocated. %d allocated\n",(sizeMax*sizeof(double*))); if(eVectors) for(i=0;i<sizeMax;i++) { eVectors[i] = (double*)malloc(sizeMax*sizeof(double)); printf("eVectors %d-th element allocated. %d allocated\n",i,(sizeMax*sizeof(double))); } eValuesPrev = (double*)malloc(sizeMax*sizeof(double)); printf("eValuesPrev allocated. %d allocated\n",(sizeMax*sizeof(double))); eVectorsPrev = (double**)malloc(sizeMax*sizeof(double*)); printf("eVectorsPrev allocated. %d allocated\n",(sizeMax*sizeof(double*))); if(eVectorsPrev) for(i=0;i<sizeMax;i++) { eVectorsPrev[i] = (double*)malloc(sizeMax*sizeof(double)); printf("eVectorsPrev %d-th element allocated. %d allocated\n",i,(sizeMax*sizeof(double))); } Log: nDim = 2485 sizeMax = 70 End hamilt alloc. 19880 allocated End transProb alloc. 39200 allocated eValues allocated. 560 allocated eVectors allocated. 280 allocated So it crashes at the start of the loop of allocation. If i delete this loop it crashes at the next line of allocation. Does it mean that with the numbers like this i have not enough memory?? Thank you.

    Read the article

  • Checking Available Memory allocation in C#

    - by Jepe d Hepe
    i need to create a function in my application to set its available memory usage. What i want to do is when the application is running, and it reaches to the set memory settings, i'll have to switch from saving to the memory to saving to a file to the local drive to avoid application hang. Is this a better way to do? What things to consider when doing this in terms of memory allocation? Hope you understand :) Thanks, Jepe

    Read the article

  • C# Class Library wont register for COM

    - by Jordan S
    Hello All, I am trying to gain access to a .NET class library in Microsoft Excel. To do this I know that the .NET class library must be registered with COM. So I tried going to my Assembly Info and Setting COM Visible to true. Then on the build tab I set Register for COM Interop for true also. I checked the AssemblyInfo.cs file and it does contain [assembly: ComVisible(true)]. But for some reason when I try to add a reference to the Class Lib in Excel the namespace does not show up in the list. I made a quick test Class library with nothing in it and did the same thing (set COM Vis = true , and Register For COM Interop = true) and that one does show up on the list of available references. I can't figure out what the difference is between the two classes. I am not sure if my class is actually being registered for COM interop or not. Does anyone know what I can do to fix this???

    Read the article

  • Delphi - How to register a custom form...

    - by durumdara
    Hi! D6 Prof. Because of Z-Order problem I created a new form. I want to register this custom form in Delphi, to I can use it as normal form, and to I can replace my forms with this - to avoid Z-Order problems. But I don't know, how to do it. I created the class, but how to register? How to force Delphi to show it under "New..." menu? Thanks for your help: dd

    Read the article

  • [NASM] How do I print out the content of a register in Hex

    - by Johnny ASM
    Hi, I'm currently getting started with NASM and wanted to know, how to output the contents of a register with NASM in Hexadecimal. I can output the content of eax with section .bss reg_buf: resb 4 . . . print_register: mov [reg_buf], eax mov eax, SYS_WRITE mov ebx, SYS_OUT mov ecx, reg_buf mov edx, 4 int 80h ret Let's say eax contains 0x44444444 then the output would be "DDDD". Apparently each pair of "44" is interpreted as 'D'. My ASCII table approves this. But how do I get my program to output the actual register content (0x44444444)?

    Read the article

  • Memory allocation in case of static variables

    - by eSKay
    I am always confused about static variables, and the way memory allocation happens for them. For example: int a = 1; const int b = 2; static const int c = 3; int foo(int &arg){ arg++; return arg; } How is the memory allocated for a,b and c? What is the difference (in terms of memory) if I call foo(a), foo(b) and foo(c)?

    Read the article

  • Another dynamic memory allocation bug.

    - by m4design
    I'm trying to allocate memory for a multidimensional array (8 rows, 3 columns). Here's the code for the allocation (I'm sure the error is clear for you) char **ptr = (char **) malloc( sizeof(char) * 8); for (i = 0; i < 3; i++) ptr[i] = (char *) malloc( sizeof(char) * 3); The crash happens when I reference this: ptr[3][0]; Unhandled exception at 0x0135144d in xxxx.exe: 0xC0000005: Access violation writing location 0xabababab. Are there any recommended references/readings for this kind of subject? Thanks.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >