Jump to content

electronuke2

Member
  • Posts

    10
  • Joined

  • Last visited

Awards

This user doesn't have any awards

Profile Information

  • Gender
    Male

electronuke2's Achievements

  1. I keep getting the same error everytime I import resources, No module named resource. How do I fix that?
  2. I found a nice way to get the answer through hard research, but now I need to find how much memory it used. so basically, I converted everything except for Runtime rt = Runtime.getRuntime(); System.out.println("Used Memory: " + (rt.totalMemory() - rt.freeMemory())/1024 + " KBytes"); Please just convert that one.
  3. Can somebody convert this into python somehow? package slotmachinerunner; import java.util.Scanner; /** * * @author */ public class SlotMachineRunner { public static void main(String[] args) { Scanner input = new Scanner(System.in); Runtime rt = Runtime.getRuntime(); System.out.println("Used Memory: " + (rt.totalMemory() - rt.freeMemory())/1024 + " KBytes"); SlotMachine stuff = new SlotMachine(); stuff.changeNumber(); System.out.println(stuff.getRandomNumber()); stuff.changeNumber(); System.out.println(stuff.getRandomNumber()); stuff.changeNumber(); System.out.println(stuff.getRandomNumber()); System.out.println("Used Memory: " + (rt.totalMemory() - rt.freeMemory())/1024 + " KBytes"); } } package slotmachinerunner; import java.util.Random; /** * * @author */ public class SlotMachine { private int randomNum; public SlotMachine(){ randomNum = 0; } public void changeNumber(){ Random rn = new Random(); int n = 4; int i = rn.nextInt() % n; randomNum = 4 + i; } public int getRandomNumber(){ return randomNum; } }
  4. Dang it, do you have anything for C++ in Windows. The things on C++ shortcut is only for Linux and doesn't work on Windows. (I tried)
  5. He is. I already contacted him. No info so far that he has will help me too much either.
  6. I tried to used task manager first, but it is very inconsistent. I figured that it was possible somehow to see how much memory a program in C++ would use just like java and python (and pretty much all the other languages that I know). And I am running windows. If anybody can just copy and paste some code or something, it would be so much easier.
  7. Nope, still nothing. It literally doesn't show me anything. I can't find a tool to say how much memory is used, I compiled one of my programs and it showed nothing but a Done! and even ran it and got nothing.
  8. Well that just told me that the IDE I am using (Dev-C++) is just retarded one. I'll get back to you and mark this as solved if this works on NetBeans or something else
  9. Ok, this post didn't answer my question, it just said memory management in C++ is very very important and everything around the actual answer. "looking at the tasks currently used memory will give you the exact amount of memory currently in use by the process" is kind of unclear since you can't just look at the tasks. What I want are lines of code to make it output how much memory the program and the IDE uses before running the program.
  10. I am currently working on a project that compares how different three different languages (Java, C++, Python) handle things memory usage wise. I currently know that the JVM will have a major impact on this. To do so, I am programming 5 programs in each language with the same logic(goal) in each of them. I know for a fact that the methods Java will take will be different because the JVM instantly does stuff(like randomize the randomizer for you) so no extra memory will be consumed. The problem I am currently running into is with C++. With Java, I have currently programmed all 5 programs and each program has Runtime rt = Runtime.getRuntime(); System.out.println("Used Memory: " + (rt.totalMemory() - rt.freeMemory())/1024 + "KBytes"); in the front(main) and System.out.println("Used Memory: " + (rt.totalMemory() - rt.freeMemory())/1024 + "KBytes"); in the back of the runner(main) of the program. This works perfectly by showing how much memory was originally used and then how much was used after the program was run, so if you subtract them, it shows how much memory the program actually uses. The problem now is C++. I need a few lines such as the code above to see how much memory was originally used and how much the program uses.
×