EzDevInfo.com

64bit interview questions

Top 64bit frequently asked interview questions

How can I tell if I'm running in 64-bit JVM or 32-bit JVM (from within a program)?

How can I tell if the JVM my application runs in is 32 bit or 64-bit? Specifically, what function or preference do I access to detect this within the program?


Source: (StackOverflow)

"Changes to 64-bit applications are not allowed" when debugging in Visual Studio 2008

I'm using Visual Studio 2008, C#. I try to use edit-and-continue (edit the code while debugging), and get this exception:

"Changes to 64-bit applications are not allowed"

Why is that? Is there a workaround?


Source: (StackOverflow)

Advertisements

Force x86 CLR on an 'Any CPU' .NET assembly

In .NET, the 'Platform Target: Any CPU' compiler option allows a .NET assembly to run as 64 bit on a x64 machine, and 32 bit on an x86 machine. It is also possible to force an assembly to run as x86 on an x64 machine using the 'Platform Target: x86' compiler option.

Is it possible to run an assembly with the 'Any CPU' flag, but determine whether it should be run in the x86 or x64 CLR? Normally this decision is made by the CLR/OS Loader (as is my understanding) based on the bitness of the underlying system.

I am trying to write a C# .NET application that can interact with (read: inject code into) other running processes. x64 processes can only inject into other x64 processes, and the same with x86. Ideally, I would like to take advantage of JIT compilation and the Any CPU option to allow a single application to be used to inject into either x64 or x86 processes (on an x64 machine).

The idea is that the application would be compiled as Any CPU. On an x64 machine, it would run as x64. If the target process is x86, it should relaunch itself, forcing the CLR to run it as x86. Is this possible?


Source: (StackOverflow)

Reading 64bit Registry from a 32bit application

I have a c# unit test project that is compiled for AnyCPU. Our build server is a 64bit machine, and has a 64bit SQL Express instance installed.

The test project uses code similar to the following to identify the path to the .MDF files:

    private string GetExpressPath()
    {
        RegistryKey sqlServerKey = Registry.LocalMachine.OpenSubKey( @"SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL" );
        string sqlExpressKeyName = (string) sqlServerKey.GetValue( "SQLEXPRESS" );
        RegistryKey sqlInstanceSetupKey = sqlServerKey.OpenSubKey( sqlExpressKeyName + @"\Setup" );
        return sqlInstanceSetupKey.GetValue( "SQLDataRoot" ).ToString();
    }

This code works fine on our 32bit workstations, and did work ok on the build server until I recently enabled code coverage analysis with NCover. Because NCover uses a 32bit COM component, the test runner (Gallio) runs as a 32bit process.

Checking the registry, there is no "Instance Names" key under

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server

Is there a way for an application running in 32bit mode to access the registry outside Wow6432Node?


Source: (StackOverflow)

Detect whether current Windows version is 32 bit or 64 bit

Believe it or not, my installer is so old that it doesn't have an option to detect the 64-bit version of Windows.

Is there a Windows DLL call or (even better) an environment variable that would give that information for Windows XP and Windows Vista?

One possible solution

I see that Wikipedia states that the 64-bit version of Windows XP and Windows Vista have a unique environment variable: %ProgramW6432%, so I'm guessing that'd be empty on 32-bit Windows.

This variable points to Program Files directory, which stores all the installed program of Windows and others. The default on English-language systems is C:\Program Files. In 64-bit editions of Windows (XP, 2003, Vista), there are also %ProgramFiles(x86)% which defaults to C:\Program Files (x86) and %ProgramW6432% which defaults to C:\Program Files. The %ProgramFiles% itself depends on whether the process requesting the environment variable is itself 32-bit or 64-bit (this is caused by Windows-on-Windows 64-bit redirection).


Source: (StackOverflow)

Unable to install Android Studio in Ubuntu

My operating system is Ubuntu gnome 14.04, ram=4gb, java 8 jdk, jre 8.

When I was installing the Android Studio all was fine but a message appears saying:

Unable to run mksdcard SDK tool

how can i install Android Studio correctly?

thanks


Source: (StackOverflow)

Detect 64-bit or 32-bit Windows from User Agent or Javascript?

I want to offer the right version of a download. The versions I have are:

  • 32-bit Windows
  • 64-bit Windows
  • Linux

Detecting Linux using the User Agent field is easy; but is it possible to reliably figure out if Windows is 32-bit or 64-bit?

Users might be using weird browsers - IE and Firefox are common, and we probably have an Opera user somewhere; maybe a Chrome user too. I know that 64-bit Windows 7 ships with 32-bit and 64-bit versions of IE, and I'd like to send them both the 64-bit version of my download.

(Edited to add: I know that I should provide all the options, and I will. But people don't read the options. So I wanted to provide the right download by default, to improve usability. Of course, while this is helpful if I get it right, it's extremely unhelpful if I get it wrong. And from the answers so far, it doesn't look like there's a reliable way of doing this).


Source: (StackOverflow)

System.BadImageFormatException: Could not load file or assembly (from installutil.exe)

I am trying to install a Windows service using InstallUtil.exe and am getting the error message

System.BadImageFormatException: Could not load file or assembly '{xxx.exe}' or one of its dependencies. An attempt was made to load a program with an incorrect format.

What gives?


EDIT: (Not by OP) Full message extracted from dup getting way more hits [for googleability]:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>InstallUtil.exe C:\xxx.exe Microsoft (R) .NET Framework Installation utility Version 4.0.30319.1 Copyright (c) Microsoft Corporation. All rights reserved.

Exception occurred while initializing the installation: System.BadImageFormatException: Could not load file or assembly 'file:///C:\xxx.exe' or one of its dependencies. An attempt was made to load a program with an incorrect format..


Source: (StackOverflow)

A simple "Hello World" needs 10G virtual memory on a 64-bit machine vs 1G at 32-bit?

Running a simple Java program on our production machine, I noticed that this program eats up more 10G virt. I know that virtual memory is not that relevant, but at least I would like to understand why this is needed.

public class Main {
  public static void main(String[] args) {
        System.out.println("Hello World!");
        try {
                Thread.sleep(10000);
        } catch(InterruptedException e) {
                /* ignored */
        }
  }
}

Heres what top is saying when i run that little program:

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
18764 myuser    20   0 10.2g  20m 8128 S  1.7  0.1   0:00.05 java

Does anyone know why this is happening?

uname -a says:

Linux m4fxhpsrm1dg 2.6.32-358.18.1.el6.x86_64 #1 SMP Fri Aug 2 17:04:38 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux

On an older 32bit-linux machine the same program consumes only about 1G virt. The old machine has 4GB RAM, the new one 32GB.


Source: (StackOverflow)

The application was unable to start correctly (0xc000007b)

I have a client/server app which I have been developing on a single PC. Now it needs two serial ports, so I borrowed a PC from a friend.

When I build my app and try to run or debug it (whether in the Delphi IDE or from Windows File manager), it errors "The application was unable to start correctly (0xc000007b)".

Googling doesn't bring up much, but seems to indicate that this is nothing Delphi specific and happens with other apps. It seems to be caused by calling into a 32 bit DLL from a 64 bit app or vice versa.

  • both PCs are Windows 7, 64 bit
  • both have Delphi Xe2 starter edition which can only handle 32 bits
  • The app runs fine on my PC, but not on my friend's
  • Other Delphi apps run just fine on my friend's PC

Can anyone give me a hint as to how to track this down?


Source: (StackOverflow)

What is the bit size of long on 64-bit Windows?

Not to long ago, someone told me that long are not 64 bits on 64 bit machines and I should always use int. This did not make sense to me. I have seen docs (such as the one on Apple's official site) say that long are indeed 64 bits when compiling for a 64-bit CPU. I looked up what it was on 64-bit Windows and found

  • Windows: long and int remain 32-bit in length, and special new data types are defined for 64-bit integers.

(from http://www.intel.com/cd/ids/developer/asmo-na/eng/197664.htm?page=2)

What should I use? Should I define something like uw, sw ((un)signed width) as a long if not on Windows, and otherwise do a check on the target CPU bitsize?


Source: (StackOverflow)

can I get Memcached running on a Windows (x64) 64bit environment?

Does anyone know IF, WHEN or HOW I can get Memcached running on a Windows 64bit environment?

I'm setting up a new hosting solution and would much prefer to run a 64bit OS, and since it's an ASP.Net MVC solution with SQL Server DB, the OS is either going to be Windows Server 2003 or (hopfully!) 2008.

I know that this could spill over into a debate regarding 32bit vs 64bit on servers, but let's just say that my preference is 64bit and that I have some very good reasons.

So far, I've tried a number of options and found a bit of help related to getting this up on a 32bit machine (and succeeded I might add), but since the original Windows port is Win32 specific, this is hardly going to help when installing as a service on x64. It also has a dependency on the libevent for which I can only get a Win32 compiled version.

I suspect that simply loading all this up in C++ and hitting "compile" (for 64bit) wouldn't work, not least because of the intricate differences in 32 and 64bit architectures, but I'm wondering if anyone is workng on getting this off the ground? Unfortunately, my expertise lie in managed code (C#) only, otherwise I would try and take this on myself, but I can't believe I'm the only guy out there trying to get memcached running on a 64 bit Windows server....am I??

Any help or recommendations appreciated...


Update

Yes I'm afraid I'm still looking for an answer to this - all my efforts (with my pathetic C++ skills) to make a stable build have failed - I've trashed one server and 3 VM's just trying it out so now I turn to the real experts. Is anyone planning on porting this to 64bit? Or are you really suggesting that I use MS Velocity instead? I shudder at the thought...


Update: @Lars - I do use Enyim actually - it's very good, but what you're referring to is a client, rather than the server part.

@DannySmurf - I've only been able to install it as a service on a 32 bit OS. 64 bit OS rejects the installation of this Win32 service. Of course yes, lots of Win32 code works seamlessly on x64 architecture, hence you can run 32bit apps (like Office for instance) or games on Vista/XP 64 etc, but this doesn't translate directly when it comes to services. I'm no expert, I suspect that it has to do with the syncs or eventing that services need to subscribe to, and I suspect that 64 and 32 don't play nicely. I'm happy to be corrected on any of this, but to answer your question - yes I have tried.

@OJ - thanks very much for the straight-forward response. I thought as much, but wasn't sure if anyone else had suggestions or had already gone down this route. Maybe when StackOverflow is LIVE, then more people will respond and let me know if this is something being looked into, and although I can try and compile it myself - I simply can't "trust" (with my C++ experience level) that it would provide "Enterprise Level" reliability in such a crucial component of large scalable solutions. I think it would need educated intervention rather than my unsanitised experimental approach before I could be confident. One little oversight on my part, could bring the site down. Oh well... till next time...


Source: (StackOverflow)

Conditionally use 32/64 bit reference when building in Visual Studio

I have a project that builds in 32/64-bit and has corresponding 32/64-bit dependencies. I want to be able to switch configurations and have the correct reference used, but I don't know how to tell Visual Studio to use the architecture-appropriate dependency.

Maybe I'm going about this the wrong way, but I want to be able to switch between x86 and x64 in the configuration dropdown, and have the referenced DLL be the right bitness.


Source: (StackOverflow)

Java 32-bit vs 64-bit compatibility

Will Java code built and compiled against a 32-bit JDK into 32-bit byte code work in a 64-bit JVM? Or does a 64-bit JVM require 64-bit byte code?

To give a little more detail, I have code that was working in a Solaris environment running a 32-bit JVM, but now I'm getting issues after upgrading the JDK and Weblogic Server to 64-bit.


Source: (StackOverflow)

Android SDK on a 64-bit linux machine

Is it possible to develop using the Android SDK on a 64-bit linux machine. The available SDK downloads seem to be just for 32-bit versions of Linux.


Source: (StackOverflow)