Daily Archives

Articles indexed Sunday March 14 2010

Page 25/89 | < Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >

  • Why is it a bad practice to call System.gc?

    - by zneak
    After answering to a question about how to force-free objects in Java (the guy was clearing a 1.5GB HashMap) with System.gc(), I've been told it's a bad practice to call System.gc() manually, but the comments seemed mitigated about it. So much that no one dared to upvote it, nor downvote it. I've been told there it's a bad practice, but then I've also been told garbage collector runs don't systematically stop the world anymore, and that it could also be only seen as a hint, so I'm kind of at loss. I do understand that usually the JVM knows better than you when it needs to reclaim memory. I also understand that worrying about a few kilobytes of data is silly. And I also understand that even megabytes of data isn't what it was a few years back. But still, 1.5 gigabyte? And you know there's like 1.5 GB of data hanging around in memory; it's not like it's a shot in the dark. Is System.gc() systematically bad, or is there some point at which it becomes okay? So the question is actually double: Why is it or not a bad practice to call System.gc()? Is it really a hint under certain implementations, or is it always a full collection cycle? Are there really garbage collector implementations that can do their work without stopping the world? Please shed some light over the various assertions people have made. Where's the threshold? Is it never a good idea to call System.gc(), or are there times when it's acceptable? If any, what are those times?

    Read the article

  • Comparing COUNT values within a query?

    - by outsyncof
    I have the following tables in a relation: person(ssn,sex) employment(ssn,workweeksperyear) assume ssn is a key. My assignment was to do this: Given as input the number of weeks per year a person has worked, determine whether there are more males than females who work more weeks than the input value. SELECT COUNT(sex) AS NumMales FROM person WHERE sex = 'Male' AND ssn IN (SELECT ssn FROM employment WHERE workweeksperyear > 48); The above query gets me the number of males for an input value and I could do the same for number of females but how do I compare the 2 results? Any help will be greatly appreciated!

    Read the article

  • Volatile or synchronized for primitive type?

    - by DKSRathore
    In java, assignment is atomic if the size of the variable is less that or equal to 32 bits but is not if more than 32 bits. What(volatile/synchronized) would be more efficient to use in case of double or long assignment. like, volatile double x = y; synchronized is not applicable with primitive argument. How do i use synchronized in this case. Of course I don't want to lock my class. so this should not be used.

    Read the article

  • Flash player "now playing list" without interrupting current song

    - by Shanon
    I am designing a website that plays music. I need a flash player that has or can handle a now playing list. The problem I am facing is that I cannot update the playlist without refreshing the player which means it will interrupt the song that is currently playing. I have trying with JW player in particular so far and have not been successful. All i am able to do is pass a playlist as an xml file but not able to update it without refreshing the playlist. Is there any other player that would better suit my needs? Is there a way i can do this with jw player itself

    Read the article

  • JSON serialization of c# enum as string

    - by ob
    I have a class that contains an enum property, and upon serializing the object using JavaScriptSerializer, my json result contains the integer value of the enumeration rather than its string "name". Is there a way to get the enum as a string in my json without having to create a custom JavaScriptConverter? Perhaps there's an attribute that I could decorate the enum definition, or object property, with? As an example: enum Gender { Male, Female } class Person { int Age { get; set; } Gender Gender { get; set; } } desired json result: { "Age": 35, "Gender": "Male" }

    Read the article

  • List of Character Encodings

    - by helpme
    Is There A Book or Site That Teaches And Also Includes A Complete List of Character Encoding's That Includes Hexadecimal, Decimal and Name Versions? If you can name a couple of books and sites, that would be very helpful thank you.

    Read the article

  • Bluetooth connect to a RS232 adapter in android

    - by ThePosey
    Hello All, I am trying to use the Bluetooth Chat sample API app that google provides to connect to a bluetooth RS232 adapter hooked up to another device. Here is the app for reference: http://developer.android.com/resources/samples/BluetoothChat/index.html And here is the spec sheet for the RS232 connector just for reference: http://serialio.com/download/Docs/BlueSnap-guide-4.77%5FCommands.pdf Well the problem is that when I go to connect to the device with: mmSocket.connect(); (BluetoothSocket::connect()) I always get an IOException error thrown by the connect method. When I do a toString on the exception I get "Service discovery failed". My question is mostly what are the cases that would cause an IOException to get thrown in the connect method? I know those are in the source somewhere but I don't know exactly how the java layer that you write apps in and the C/C++ layer that contains the actual stacks interface. I know that it uses the bluez bluetooth stack which is written in C/C++ but not sure how that ties into the java layer which is what I would think is throwing the exception. Any help on pointing me to where I can try to dissect this issue would be incredible. Also just to note I am able to pair with the RS232 adapter just fine but I am never able to actually connect. Here is the logcat output for more reference: I/ActivityManager( 1018): Displayed activity com.example.android.BluetoothChat/.DeviceListActivity: 326 ms (total 326 ms) E/BluetoothService.cpp( 1018): stopDiscoveryNative: D-Bus error in StopDiscovery: org.bluez.Error.Failed (Invalid discovery session) D/BluetoothChat( 1729): onActivityResult -1 D/BluetoothChatService( 1729): connect to: 00:06:66:03:0C:51 D/BluetoothChatService( 1729): setState() STATE_LISTEN - STATE_CONNECTING E/BluetoothChat( 1729): + ON RESUME + I/BluetoothChat( 1729): MESSAGE_STATE_CHANGE: STATE_CONNECTING I/BluetoothChatService( 1729): BEGIN mConnectThread E/BluetoothService.cpp( 1018): stopDiscoveryNative: D-Bus error in StopDiscovery: org.bluez.Error.Failed (Invalid discovery session) E/BluetoothEventLoop.cpp( 1018): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/1498/hci0/dev_00_06_66_03_0C_51 I/BluetoothChatService( 1729): CONNECTION FAIL TOSTRING: java.io.IOException: Service discovery failed D/BluetoothChatService( 1729): setState() STATE_CONNECTING - STATE_LISTEN D/BluetoothChatService( 1729): start D/BluetoothChatService( 1729): setState() STATE_LISTEN - STATE_LISTEN I/BluetoothChat( 1729): MESSAGE_STATE_CHANGE: STATE_LISTEN V/BluetoothEventRedirector( 1080): Received android.bleutooth.device.action.UUID I/NotificationService( 1018): enqueueToast pkg=com.example.android.BluetoothChat callback=android.app.ITransientNotification$Stub$Proxy@446327c8 duration=0 I/BluetoothChat( 1729): MESSAGE_STATE_CHANGE: STATE_LISTEN E/BluetoothEventLoop.cpp( 1018): event_filter: Received signal org.bluez.Device:PropertyChanged from /org/bluez/1498/hci0/dev_00_06_66_03_0C_51 V/BluetoothEventRedirector( 1080): Received android.bleutooth.device.action.UUID The device I'm trying to connect to is the 00:06:66:03:0C:51 which I can scan for and apparently pair with just fine.

    Read the article

  • Java: volatile guarantees and out-of-order execution

    - by WizardOfOdds
    Note that this question is solely about the volatile keyword and the volatile guarantees: it is not about the synchronized keyword (so please don't answer "you must use synchronize" for I don't have any issue to solve: I simply want to understand the volatile guarantees (or lack of guarantees) regarding out-of-order execution). Say we have an object containing two volatile String references that are initialized to null by the constructor and that we have only one way to modify the two String: by calling setBoth(...) and that we can only set their references afterwards to non-null reference (only the constructor is allowed to set them to null). For example (it's just an example, there's no question yet): public class SO { private volatile String a; private volatile String b; public SO() { a = null; b = null; } public void setBoth( @NotNull final String one, @NotNull final String two ) { a = one; b = two; } public String getA() { return a; } public String getB() { return b; } } In setBoth(...), the line assigning the non-null parameter "a" appears before the line assigning the non-null parameter "b". Then if I do this (once again, there's no question, the question is coming next): if ( so.getB() != null ) { System.out.println( so.getA().length ); } Am I correct in my understanding that due to out-of-order execution I can get a NullPointerException? In other words: there's no guarantee that because I read a non-null "b" I'll read a non-null "a"? Because due to out-of-order (multi)processor and the way volatile works "b" could be assigned before "a"? volatile guarantees that reads subsequent to a write shall always see the last written value, but here there's an out-of-order "issue" right? (once again, the "issue" is made on purpose to try to understand the semantics of the volatile keyword and the Java Memory Model, not to solve a problem).

    Read the article

  • How can I see debug messages with Mono apps?

    - by nubela
    Hi, I have various Debug.WriteLine messages, I tried to see those messages using export MONO_DEBUG_LEVEL=debug, but I end up getting other irrelevant debug messages which was not outputted by my code. What should I do to see the debug messages? I'm using Linux :) Thanks.

    Read the article

  • Using the Reactive Extensions with the Silverlight Toolkit and MEF

    - by Bobby Diaz
    I have come across several instances of people having trouble using the new Reactive Extensions (v1.0.2317) in projects that reference the Silverlight Toolkit (Nov09) due to the fact that the original release of the Rx Framework (v1.0.0.0) was bundled with the Toolkit.  The trouble really becomes evident if you are using the Managed Extensibility Framework (MEF) to discover and compose portions of your application.   If you are using the CompositionInitializer, or any other mechanism that probes all of the loaded assemblies for valid exports, you will likely receive the following error: Inspecting the LoaderExceptions property yields the following: System.IO.FileNotFoundException: Could not load file or assembly 'System.Reactive, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1b331ac6720247d9' or one of its dependencies. The system cannot find the file specified.  File name: 'System.Reactive, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1b331ac6720247d9' This is due to some of the Toolkit assemblies referencing the older System.Reactive.dll.  I was able to work around the issue by bypassing the automatic probing of loaded assemblies and instead specified which assemblies my exports could be found.     public MainPage()     {         InitializeComponent();           // the following line causes a ReflectionTypeLoadException         //CompositionInitializer.SatisfyImports(this);           // skip the toolkit assemblies by specifying assemblies         var catalog = new AssemblyCatalog(GetType().Assembly);         var container = new CompositionContainer(catalog);         container.ComposeParts(this);           ShowReferences();     } With some simple xaml, I was able to print out exactly which libraries are currently loaded in the application. You can download the sample project to run it for yourself! Hope that helps!

    Read the article

  • Why is it a bad idea to use multiple NAT layers or is it?

    - by iamrohitbanga
    The computer network of an organization has a NAT with 192.168/16 IP address range. There is a department with a server that has an IP address 192.168.x.y and this server handles hosts of this department with another NAT with the IP address range 172.16/16. Thus there are 2 layers of NAT. Why don't they have subnetting instead. This would allow easy routing. I feel multiple layers of NAT can cause performance losses. Could you please help me compare the two design strategies.

    Read the article

  • ^+Left Arrow and ^+Right Arrow suddenly stopped working on OS X

    - by user31122
    Hello. I'm not really sure what to make of this. The key combination of ^? and ^? have stopped working for one of the two users on my OS X installation. I use these keys all the time (switching tabs in terminal, IntelliJ primarily), and it's driving me crazy. On one user account, it works fine. On the other, it doesn't. This happened today and nothing significant comes to mind that would have caused some weird keybinding issue. If anyone has heard of or experienced anything like this, I would very much appreciate your advice! Thanks.

    Read the article

  • Any reason not to disable Windows kernel paging?

    - by Nathaniel
    So I'm planning on eventually going to 2 GB (mobo max) RAM from 1 GB, and I want to disable kernel paging once I do, because I've heard it can give a performance boost (and that I believe). Any reason not to do it or any general thoughts about it? Edit: for clarification, this is not disabling general RAM paging. This is disabling having kernel memory paged (or at least parts of it, as Charlls noted).

    Read the article

  • RUNNING PHP IN NETBEANS

    - by user216112
    i have netbeans 6.8 with all bundle faetures. now i m running my php file Binary Search h1 {color: blue} Computer guess number by using binary search Input your hidden number: (1-99) Here; } else { if ($max_num==-1 && $min_num==-1) { $max_num = 100; $min_num = 0; $result_num = $hid_num; } else { if ($comparision == "bigger") { $min_num = $guess_num; } else if ($comparision == "smaller") { $max_num = $guess_num; } } $guess_num = ($max_num + $min_num)/2; setType($guess_num,"integer"); print "Computer guess $guess_num "; if ($guess_num == $result_num) { $flag_num = -1; } if ($flag_num == -1) { print Congratulation, Computer win " Here; } else { print Your intruction: Bigger Smaller Here; } } ? but the erreor coming in the "HTTP 404 NOT FOUND" I THINK SERVER HAS BEEN NOT BEEN SET.SO WHAT SHOULD I DO TO RUN IT

    Read the article

  • How to create Non Resizable custom server control

    - by wonde
    Hi guys, I am building a custom web panel control for specific purpose.I want the control be fixed with specific width and height so that not to be resized in design mode as well as from property window.How can I do thing. It is very important and urgent.I will appreciate if you can help me.

    Read the article

  • help with accessing an array/object

    - by noname
    i have printed out the contents of an array/object (named 'document') with print_r. it looks like this: Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 7006276 ) [name] => Arnessysla [type] => region [latitude] => 64.5833 [longitude] => -21.8833 [entities] => SimpleXMLElement Object ( ) ) ) how do i get the 'entities' contents? i've tried this: $document[0]-attributes['entities'] but it didnt work!

    Read the article

  • navbar hover issue in ie8

    - by Joel
    I'm having a problem with a child list not hovering correctly in IE8. Other browsers and IE7 seem to work fine. Here is the site: http://rattletree.com/index_1.php If you hover over the nav bars you'll see the sub-list come into view. You can see that the arrow image is not below the navbar in IE8 only. html: <div id="navbar2"> <ul id="navbar"> <li id="index"><a href="index.php">About Rattletree</a></li> <li id="upcomingshows"><a href="upcomingshows.php">Calendar</a></li> <li id="booking"><a href="booking.php">Contact</a> <ul class="innerlist"> <li class="innerlist"><img class="arrowAdjust" src="images/curved_arrow.png"</img><a href="#">Booking Information</a></li> <li class="innerlist"><a href="#">Press</a></li> </ul> </li> <li id="instruments"><a href="instruments.php">The Band</a> <ul class="innerlist"> <li class="innerlist"><img class="arrowAdjust" src="images/curved_arrow.png"</img><a href="#">The Instruments</a></li> <li class="innerlist"><a href="#">The Players</a></li> </ul> </li> <li id="classes"><a href="classes.php">Sights &amp; Sounds</a> <ul class="innerlist"> <li class="innerlist"><img class="arrowAdjust" src="images/curved_arrow.png"</img><a href="#">Listen</a></li> <li class="innerlist"><a href="#">Photos</a></li> <li class="innerlist"><a href="#">Video</a></li> </ul> </li> <li id"classes"><a href="classes.php">Workshops &amp; Classes</a></li> </ul> </div> and css: /* OUTER LIST STYLING */ div#navbar2 { position:relative; width: 100%; border-top: solid #000 1px; border-bottom: solid #546F8B 1px; background-color: #546F8B; } div#navbar2 ul#navbar { padding: 0px; margin: 10px 0; font-family: Arial, Helvetica, sans-serif; font-size: 16px; letter-spacing:1px; color: #FFF; white-space: nowrap; display:block; } div#navbar2 ul#navbar li { position:relative; margin: 0px; padding:0px; list-style-type: none; display:inline; } div#navbar2 li a { text-decoration: none; color: #fff; margin:0; padding: 11px 12px; } div#navbar2 li a:link { color: #FFF: } div#navbar2 li a:visited { color: #ffffff; } div#navbar2 li a:hover { color: #000; background-color: #FDFFC9; } /* INNER LIST STYLING */ div#navbar2 ul#navbar li ul.innerlist{ display: none; color:#000; } div#navbar2 ul#navbar li ul.innerlist li{ color:#000; } div#navbar2 ul#navbar li:hover ul.innerlist { position: absolute; display: inline; left: 0; width: 100%; margin: 30px 0 0px 0px; padding: 0; color:#000; } div#navbar2 ul#navbar li.innerlist a { text-decoration: none; font-weight:bold; color: #000; padding: 10px 15px 20px 15px; margin:0; } div#navbar2 li.innerlist a:link { color: #000: } div#navbar2 li.innerlist a:visited { color: #000; } div#navbar2 ul#navbar li.innerlist a:hover { color: #e62d31; background-color:transparent; } img.arrowAdjust{ padding:0px 0 0 20px; margin:0; }

    Read the article

  • Jad file download link for my website

    - by Jareim
    Hi sir/madam! I am putting up a small website via webs.com for me and my friends that could also be accessible via wap, i.e. mobile internet, and I want to add links to my site that downloads .jar files. I uploaded the files on my site, and links to the .jar files went fine, but I also need links for .jad files (for some mobile phones that require .jad files FIRST then .jar). I tried doing a regular link for the .jad files, but it simply displayed the content of the .jad file. It wasn't installed or downloaded. What should I do? Or am I at a wrong website? Thanks!

    Read the article

  • How to convert between different currencies?

    - by sil3nt
    Hey there, this is part of a question i got in class, im at the final stretch but this has become a major problem. In it im given a certain value which is called the "gold value" and it is 40.5, this value changes in input. and i have these constants const int RUBIES_PER_DIAMOND = 5; // relative values. * const int EMERALDS_PER_RUBY = 2; const int GOLDS_PER_EMERALDS = 5; const int SILVERS_PER_GOLD = 4; const int COPPERS_PER_SILVER = 5; const int DIAMOND_VALUE = 50; // gold values. * const int RUBY_VALUE = 10; const int EMERALD_VALUE = 5; const float SILVER_VALUE = 0.25; const float COPPER_VALUE = 0.05; which means that basically for every diamond there are 5 rubies, and for every ruby there are 2 emeralds. So on and so forth. and the "gold value" for every diamond for example is 50 (diamond value = 50) this is how much one diamond is worth in golds. my problem is converting 40.5 into these diamonds and ruby values. I know the answer is 4rubies and 2silvers but how do i write the algorithm for this so that it gives the best estimate for every goldvalue that comes along?? please help!, im at my wits end

    Read the article

  • Lua : Dynamicly calling a function with arguments.

    - by Tipx
    Using Lua, I'm trying to dynamicly call a function with parameters. What I want to have it done is I send a string to be parsed in a way that : 1st argument is a class instance "Handle" 2nd is the function to be called All that is left are arguments "modules" is a a table like { string= } split() is a simple parser that returns a table with indexed strings function Dynamic(msg) local args = split(msg, " ") module = args[1] table.remove(args, 1) if module then module = modules[module] command = args[1] table.remove(args, 1) if command then if not args then module[command]() else module[command](unpack(args)) -- Reference 1 end else -- Function doesnt exist end else -- Module doesnt exist end end When I try this with "ignore remove bob", by "Reference 1", it tries to call "remove" on the instance associated with "ignore" in modules, and gives the argument "bob", contained in a table (with a single value). However, on the other side of the call, the remove function does not receive the argument. I even tried to replace the "Reference 1" line with module[command]("bob") but I get the same result.

    Read the article

< Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >