Variation in sleep mode power consumption in Atmel Studio and Arduino IDE

Hello..I'm fairly experienced with Arduino and AVR chips. I was trying to put my Atmega8A, programmed using the Arduino IDE. I also implemented the power down sleep mode code using avr/sleep.h. However, the power consumption didn't seem to be low as expected. Then I wrote a blank sketch in Arduino IDE as well as Atmel Studio without any kind of sleep mode and Arduino IDE sketch was consuming much more power than the one coded in Atmel Studio. Then I tried using the sleep mode. The one done in Arduino IDE was consuming around 300uA while the one done in Atmel Studio was using just 3uA. The setup involves only an Atmega8 running @ 3.3V, 1Mhz internal oscillator with nothing connected to the chip externally other than Vcc and GND. The datasheet says the @ 3v, 4Mhz, I should be getting a power consumption of around 0.5uA. 3uA is good enough but it would be great if i could achieve what the datasheet says. Maybe the Arduino IDE keeps some peripherals running. On Atmega8, it seems that the only peripheral that seems to be ON by default is the Analog Comparator. Any tips to further reduce power consumption will be helpful.

Thanks

Turn off the ADC. Arduino sketches turn that on in init() (called before setup), and keeps the sleep power much higher than it otherwise would be.

  ADCSRA&=127; //turn off ADC,

Thanks. Will try that out and see what comes up.

Yup...turning off ADC solved the issue. Now both Atmel Studio and Arduino IDE seems to be even. However, any idea how I can achieve 0.5uA as per the datasheet. Does the savings in power down mode really depend on the system clock as all the clocks seem toe be halted in power down mode.

Is the brown out detector enabled?

According to the datasheet an enabled BOD would result in more than 3uA power down current. But the datasheet also suggests that disabling the A/D should have only saved about 160uA, not the nearly 300uA that you saw.