Low Memory Detector error when loading textures

Started by jjones7947, April 30, 2005, 16:38:40

Previous topic - Next topic

jjones7947

Cut and pasted the following texture loading method from NeHe Lesson 6:
  private int loadTexture(String path) { 
       IntBuffer? image = ByteBuffer?.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer(); 
       IL.ilGenImages(1, image); 
       IL.ilBindImage(image.get(0)); 
       IL.ilLoadImage(path); 
       IL.ilConvertImage(IL.IL_RGB, IL.IL_BYTE); 
       ByteBuffer? scratch = ByteBuffer?.allocateDirect(IL.ilGetInteger(IL.IL_IMAGE_WIDTH) * IL.ilGetInteger(IL.IL_IMAGE_HEIGHT) * 3); 
       IL.ilCopyPixels(0, 0, 0, IL.ilGetInteger(IL.IL_IMAGE_WIDTH), IL.ilGetInteger(IL.IL_IMAGE_HEIGHT), 1, IL.IL_RGB, IL.IL_BYTE, scratch); 
        
       // Create A IntBuffer? For Image Address In Memory 
       IntBuffer? buf = ByteBuffer?.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer(); 
       GL11.glGenTextures(buf); // Create Texture In OpenGL 

       GL11.glBindTexture(GL11.GL_TEXTURE_2D, buf.get(0)); 
       // Typical Texture Generation Using Data From The Image 

       // Linear Filtering 
       GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); 
       // Linear Filtering 
       GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); 
       // Generate The Texture 
       GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, IL.ilGetInteger(IL.IL_IMAGE_WIDTH),  
               IL.ilGetInteger(IL.IL_IMAGE_HEIGHT), 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, scratch); 

       return buf.get(0); // Return Image Address In Memory 
   }


Got this error when I attempted to load ~ 20 textures
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000, pid=10900, tid=10948
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0-beta2-b51 mixed mode, sharing)
# Problematic frame:
# C  0x00000000
#

---------------  T H R E A D  ---------------

Current thread (0x007369b0):  JavaThread "main" [_thread_in_native, id=10948]

siginfo: ExceptionCode=0xc0000005, reading address 0x00000000

Registers:
EAX=0x009df000, EBX=0x26b97040, ECX=0x00000000, EDX=0x00000001
ESP=0x0006f950, EBP=0x0006f990, ESI=0x26b97040, EDI=0x007369b0
EIP=0x00000000, EFLAGS=0x00010206

Top of Stack: (sp=0x0006f950)
0x0006f950:   05011a4a 00000001 009df000 00a2826f
0x0006f960:   00736a6c 0006f998 00000001 0006f9a4
0x0006f970:   00000000 0006f974 26b97040 0006f9a8
0x0006f980:   26b99a40 00000000 26b97040 0006f9a0
0x0006f990:   0006f9c8 00a22923 26b999e8 00a26449
0x0006f9a0:   00000000 22ac3eb0 00000001 0006f9ac
0x0006f9b0:   26b96fbd 0006f9d0 26b99a40 00000000
0x0006f9c0:   26b96fd8 0006f9d0 0006f9f0 00a22923 

Instructions: (pc=0x00000000)
0xfffffff0:   


Stack: [0x00030000,0x00070000),  sp=0x0006f950,  free space=254k
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  org.lwjgl.devil.IL.nilGenImages(ILjava/nio/IntBuffer;I)V+0
j  org.lwjgl.devil.IL.ilGenImages(Ljava/nio/IntBuffer;)V+13
j  core.GameFrame.loadTexture(Ljava/lang/String;)I+15
j  core.GameFrame.loadTextures()V+82
j  core.GameFrame.initGame()V+1
j  core.GameFrame.<init>()V+47
j  core.GameFrame.main([Ljava/lang/String;)V+3
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x009bc6c0 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=11276]
  0x009bb1d8 JavaThread "CompilerThread0" daemon [_thread_blocked, id=11272]
  0x009ba428 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=11268]
  0x009b77c8 JavaThread "Finalizer" daemon [_thread_blocked, id=11264]
  0x009b62c0 JavaThread "Reference Handler" daemon [_thread_blocked, id=11260]
=>0x007369b0 JavaThread "main" [_thread_in_native, id=10948]

Other Threads:
  0x009b3a38 VMThread [id=11256]
  0x009bdc48 WatcherThread [id=11280]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 def new generation   total 576K, used 240K [0x22aa0000, 0x22b40000, 0x22f80000)
  eden space 512K,  36% used [0x22aa0000, 0x22ace300, 0x22b20000)
  from space 64K,  86% used [0x22b20000, 0x22b2dd30, 0x22b30000)
  to   space 64K,   0% used [0x22b30000, 0x22b30000, 0x22b40000)
 tenured generation   total 7436K, used 4793K [0x22f80000, 0x236c3000, 0x26aa0000)
   the space 7436K,  64% used [0x22f80000, 0x2342e610, 0x2342e800, 0x236c3000)
 compacting perm gen  total 8192K, used 999K [0x26aa0000, 0x272a0000, 0x2aaa0000)
   the space 8192K,  12% used [0x26aa0000, 0x26b99e70, 0x26b9a000, 0x272a0000)
    ro space 8192K,  66% used [0x2aaa0000, 0x2aff0a70, 0x2aff0c00, 0x2b2a0000)
    rw space 12288K,  46% used [0x2b2a0000, 0x2b833ce0, 0x2b833e00, 0x2bea0000)

Dynamic libraries:
0x00400000 - 0x0040c000 	C:\Program Files\Java\jdk1.5.0\bin\javaw.exe
0x77f80000 - 0x77ffd000 	C:\WINNT\system32\ntdll.dll
0x7c2d0000 - 0x7c332000 	C:\WINNT\system32\ADVAPI32.dll
0x7c570000 - 0x7c623000 	C:\WINNT\system32\KERNEL32.DLL
0x77d30000 - 0x77da1000 	C:\WINNT\system32\RPCRT4.DLL
0x77e10000 - 0x77e6f000 	C:\WINNT\system32\USER32.dll
0x77f40000 - 0x77f7b000 	C:\WINNT\system32\GDI32.dll
0x78000000 - 0x78045000 	C:\WINNT\system32\MSVCRT.dll
0x6d630000 - 0x6d7b4000 	C:\Program Files\Java\jdk1.5.0\jre\bin\client\jvm.dll
0x77570000 - 0x775a0000 	C:\WINNT\system32\WINMM.dll
0x6d280000 - 0x6d288000 	C:\Program Files\Java\jdk1.5.0\jre\bin\hpi.dll
0x690a0000 - 0x690ab000 	C:\WINNT\system32\PSAPI.DLL
0x6d600000 - 0x6d60c000 	C:\Program Files\Java\jdk1.5.0\jre\bin\verify.dll
0x6d2f0000 - 0x6d30d000 	C:\Program Files\Java\jdk1.5.0\jre\bin\java.dll
0x6d620000 - 0x6d62f000 	C:\Program Files\Java\jdk1.5.0\jre\bin\zip.dll
0x6d000000 - 0x6d166000 	C:\Program Files\Java\jdk1.5.0\jre\bin\awt.dll
0x77800000 - 0x7781e000 	C:\WINNT\system32\WINSPOOL.DRV
0x76620000 - 0x76630000 	C:\WINNT\system32\MPR.DLL
0x75e60000 - 0x75e7a000 	C:\WINNT\system32\IMM32.dll
0x77a50000 - 0x77b3f000 	C:\WINNT\system32\ole32.dll
0x10000000 - 0x1003f000 	C:\Program Files\Java\jdk1.5.0\jre\bin\lwjgl.dll
0x5f580000 - 0x5f620000 	C:\WINNT\system32\DINPUT.dll
0x69510000 - 0x695d7000 	C:\WINNT\system32\OPENGL32.dll
0x6fac0000 - 0x6fadf000 	C:\WINNT\system32\GLU32.dll
0x51000000 - 0x51050000 	C:\WINNT\system32\DDRAW.dll
0x728a0000 - 0x728a6000 	C:\WINNT\system32\DCIMAN32.dll
0x77820000 - 0x77827000 	C:\WINNT\system32\VERSION.dll
0x759b0000 - 0x759b6000 	C:\WINNT\system32\LZ32.DLL
0x03980000 - 0x03ea6000 	C:\WINNT\system32\nvoglnt.dll
0x6f9a0000 - 0x6f9a8000 	C:\WINNT\system32\HID.DLL
0x77880000 - 0x7790e000 	C:\WINNT\system32\SETUPAPI.DLL
0x7c0f0000 - 0x7c151000 	C:\WINNT\system32\USERENV.DLL
0x71710000 - 0x71794000 	C:\WINNT\system32\COMCTL32.dll
0x05010000 - 0x0502e000 	C:\Program Files\Java\jdk1.5.0\jre\bin\lwjgl-devil.dll

VM Arguments:
jvm_args: -Djava.library.path=bin
java_command: core.GameFrame

Environment Variables:
JAVA_HOME=C:\Program Files\Java\jdk1.5.0
CLASSPATH=.;C:\PROGRA~1\JMF21~1.1E\lib\sound.jar;C:\PROGRA~1\JMF21~1.1E\lib\jmf.jar;C:\PROGRA~1\JMF21~1.1E\lib;
PATH=C:\Program Files\Java\jdk1.5.0\bin;C:\Perl\bin\;C:\WINNT\system32;C:\WINNT;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files\backburner 2\;i:\apache-ant-1.6.1\bin;i:\Program Files\Subversion\bin
USERNAME=Jones20001
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 15 Model 2 Stepping 7, GenuineIntel


---------------  S Y S T E M  ---------------

OS: Windows 2000 Build 2195 Service Pack 4

CPU:total 1 family 15, cmov, cx8, fxsr, mmx, sse, sse2, ht

Memory: 4k page, physical 1048032k(558176k free), swap 4194303k(4194303k free)

vm_info: Java HotSpot(TM) Client VM (1.5.0-beta2-b51) for windows-x86, built on May 13 2004 02:09:25 by "java_re" with MS VC++ 6.0


Something wrong with the code?
Too many textures (maybe 1 mg of file size total)?
Any suggestions?
A better way to load?

Jim

Skippy0

I don't know alot about DevIL, but you probably need to rewind() stratch.

If the video-card runs out of memory, it will either:
1) use system-memory
2) throw a neat OpenGL exception saying it ran out of memory

but not crash like that

tomb

The Low Memory Detector has nothing to do with it. It's just a thread that is running in the background, along with 5 other threads.

It looks like there is a access violation in nilGenImages. Wich means it is reading outside it's designated memory. Maybe it's doing something wacky, maybe you send in the wrong parameter.

jjones7947

Actually it was a problem with loading the textures, in that they weren"t loading.  Thanks for the help.
Jim