Why cant I delete C++ pointer in JNI DLL

Hi,
I'm new to JNI and pretty rusty on C++, normally I stick to 100% Java, however I had a need for some native magic. My code works well and does the job I needed however my (old) knowledge of C++ tells me that I need to clean my objects up when I'm done. However I am unable to delete a pointer and I'm pretty sure its got something to do with JNI and lots to do with my lack of indepth knowledge. Here's what my code does.
I have a Java app (J) that statically loads my DLL
"J" calls a native c++ function within the DLL called (S).
"S" creates a C++ object using the "new" operator, called (T).
"T" is a Thread which I then start ( it runs for 1minute)
"S" does not wait for "T" to finish, instead it returns immediately, passing the pointer to "T" back to "J"
"J" then starts a normal Java Thread and every 10secs calls a native function from the DLL, called (C), and passes the pointer to "T".
"C" then checks "T" to find out if it has finished, if not then it returns % complete as an "int". If "T" has finished it throws an Exception, and then attempts to delete "T" calling the following code :-
delete T;
T = 0;
printf("\ndone\n");However it crashed on "delete T", if I comment both these lines out everything completes ok.
My first thought was that "T" is already deleted, however I've checked and this is not the case, it still points to a valid "T" object. I know this because if I let my Java Thread continue to query for status long after "T" has stopped it still gets the last status message.
So my problem is, how do I delete "T"?. The system crashes if I try......interestingly enough though if I comment out the "delete T" line and leave the "T=0" line then I get an "Access Violation" error instead.
Does this mean that C++ does not own the object anymore (becase I passed it to Java). Does Java now own it and will it garbage collect it for me?
Thanks for any help
Chris.

Hi,
Not sure how I can pinpoint the stack corruption? Here's the JNI log produce when I use "ie=0", perhaps it would mean something to you.
# An unexpected error has been detected by HotSpot Virtual Machine:
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0afd2bb7, pid=3584, tid=1680
# Java VM: Java HotSpot(TM) Client VM (1.5.0_03-b07 mixed mode)
# Problematic frame:
# C [IEConnectionJNI.dll+0x2bb7]
--------------- T H R E A D ---------------
Current thread (0x0acc3d28): JavaThread "Thread-0" [_thread_in_native, id=1680]
siginfo: ExceptionCode=0xc0000005, reading address 0x00000010
Registers:
EAX=0x0b4cfca0, EBX=0x06c77528, ECX=0x00000000, EDX=0x0b149438
ESP=0x0b4cfc34, EBP=0x0b4cfcb0, ESI=0x0b4cfc38, EDI=0x0b4cfcb0
EIP=0x0afd2bb7, EFLAGS=0x00010246
Top of Stack: (sp=0x0b4cfc34)
0x0b4cfc34: 00001388 0acc3d28 06c77520 06c77528
0x0b4cfc44: cccccccc cccccccc cccccccc cccccccc
0x0b4cfc54: cccccccc cccccccc cccccccc cccccccc
0x0b4cfc64: cccccccc cccccccc cccccccc cccccccc
0x0b4cfc74: cccccccc cccccccc cccccccc cccccccc
0x0b4cfc84: cccccccc 0b311910 cccccccc 0b311910
0x0b4cfc94: 0b311910 cccccccc cccccccc 0b13d2d8
0x0b4cfca4: cccccccc 00a86770 00000000 0b4cfce0
Instructions: (pc=0x0afd2bb7)
0x0afd2ba7: f0 e8 ca 5f 0c 00 8b f4 68 88 13 00 00 8b 4d fc
0x0afd2bb7: 8b 51 10 52 ff 15 b8 d3 14 0b 3b f4 e8 b8 a0 00
Stack: [0x0b490000,0x0b4d0000), sp=0x0b4cfc34, free space=255k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [IEConnectionJNI.dll+0x2bb7]
j system.IEConnectionJNI.getDownloadStatus(I)Ljava/lang/String;+0
j system.IEConnectionJNI$ProgressCheck.run()V+17
v ~StubRoutines::call_stub
V [jvm.dll+0x818b8]
V [jvm.dll+0xd431d]
V [jvm.dll+0x81789]
V [jvm.dll+0x814e6]
V [jvm.dll+0x9c06b]
V [jvm.dll+0xfe7f5]
V [jvm.dll+0xfe7c3]
C [MSVCRT.dll+0x2a3b0]
C [kernel32.dll+0xb683]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j system.IEConnectionJNI.getDownloadStatus(I)Ljava/lang/String;+0
j system.IEConnectionJNI$ProgressCheck.run()V+17
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x00037180 JavaThread "DestroyJavaVM" [_thread_blocked, id=3588]
=>0x0acc3d28 JavaThread "Thread-0" [_thread_in_native, id=1680]
0x00aca528 JavaThread "Monitor Ctrl-Break" daemon [_thread_in_native, id=3660]
0x00a92730 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=2336]
0x00a913a8 JavaThread "CompilerThread0" daemon [_thread_blocked, id=3648]
0x00a90730 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=3644]
0x00a87c18 JavaThread "Finalizer" daemon [_thread_blocked, id=3640]
0x00a86810 JavaThread "Reference Handler" daemon [_thread_blocked, id=2144]
Other Threads:
0x00a84ea8 VMThread [id=3624]
0x00a93908 WatcherThread [id=3656]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap
def new generation total 576K, used 378K [0x02ad0000, 0x02b70000, 0x02fb0000)
eden space 512K, 74% used [0x02ad0000, 0x02b2eb90, 0x02b50000)
from space 64K, 0% used [0x02b50000, 0x02b50000, 0x02b60000)
to space 64K, 0% used [0x02b60000, 0x02b60000, 0x02b70000)
tenured generation total 1408K, used 0K [0x02fb0000, 0x03110000, 0x06ad0000)
the space 1408K, 0% used [0x02fb0000, 0x02fb0000, 0x02fb0200, 0x03110000)
compacting perm gen total 8192K, used 1815K [0x06ad0000, 0x072d0000, 0x0aad0000)
the space 8192K, 22% used [0x06ad0000, 0x06c95e60, 0x06c96000, 0x072d0000)
No shared spaces configured.
Dynamic libraries:
0x00400000 - 0x0040c000      C:\jdk1.5.0_03\bin\java.exe
0x7c900000 - 0x7c9b0000      C:\WINDOWS\system32\ntdll.dll
0x7c800000 - 0x7c8f4000      C:\WINDOWS\system32\kernel32.dll
0x77dd0000 - 0x77e6b000      C:\WINDOWS\system32\ADVAPI32.dll
0x77e70000 - 0x77f01000      C:\WINDOWS\system32\RPCRT4.dll
0x77c10000 - 0x77c68000      C:\WINDOWS\system32\MSVCRT.dll
0x6d6b0000 - 0x6d836000      C:\jdk1.5.0_03\jre\bin\client\jvm.dll
0x77d40000 - 0x77dd0000      C:\WINDOWS\system32\USER32.dll
0x77f10000 - 0x77f57000      C:\WINDOWS\system32\GDI32.dll
0x76b40000 - 0x76b6d000      C:\WINDOWS\system32\WINMM.dll
0x76390000 - 0x763ad000      C:\WINDOWS\system32\IMM32.DLL
0x6d2f0000 - 0x6d2f8000      C:\jdk1.5.0_03\jre\bin\hpi.dll
0x76bf0000 - 0x76bfb000      C:\WINDOWS\system32\PSAPI.DLL
0x6d680000 - 0x6d68c000      C:\jdk1.5.0_03\jre\bin\verify.dll
0x6d370000 - 0x6d38d000      C:\jdk1.5.0_03\jre\bin\java.dll
0x6d6a0000 - 0x6d6af000      C:\jdk1.5.0_03\jre\bin\zip.dll
0x10000000 - 0x10007000      C:\Program Files\JetBrains\IntelliJ IDEA 6.0\bin\breakgen.dll
0x0afd0000 - 0x0b15f000      C:\projects\relatis_systray\IEConnectionJNI.dll
0x61410000 - 0x61534000      C:\WINDOWS\system32\urlmon.dll
0x774e0000 - 0x7761d000      C:\WINDOWS\system32\ole32.dll
0x77120000 - 0x771ac000      C:\WINDOWS\system32\OLEAUT32.dll
0x77f60000 - 0x77fd6000      C:\WINDOWS\system32\SHLWAPI.dll
0x5dca0000 - 0x5dce5000      C:\WINDOWS\system32\iertutil.dll
0x5d090000 - 0x5d12a000      C:\WINDOWS\system32\COMCTL32.dll
0x771b0000 - 0x7727e000      C:\WINDOWS\system32\WININET.dll
0x003f0000 - 0x003f9000      C:\WINDOWS\system32\Normaliz.dll
0x73000000 - 0x73026000      C:\WINDOWS\system32\WINSPOOL.DRV
0x763b0000 - 0x763f9000      C:\WINDOWS\system32\comdlg32.dll
0x7c9c0000 - 0x7d1d5000      C:\WINDOWS\system32\SHELL32.dll
0x773d0000 - 0x774d3000      C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03\comctl32.dll
0x6d530000 - 0x6d543000      C:\jdk1.5.0_03\jre\bin\net.dll
0x71ab0000 - 0x71ac7000      C:\WINDOWS\system32\WS2_32.dll
0x71aa0000 - 0x71aa8000      C:\WINDOWS\system32\WS2HELP.dll
0x77fe0000 - 0x77ff1000      C:\WINDOWS\system32\Secur32.dll
0x71a50000 - 0x71a8f000      C:\WINDOWS\system32\mswsock.dll
0x662b0000 - 0x66308000      C:\WINDOWS\system32\hnetcfg.dll
0x71a90000 - 0x71a98000      C:\WINDOWS\System32\wshtcpip.dll
0x5ad70000 - 0x5ada8000      C:\WINDOWS\system32\uxtheme.dll
0x10100000 - 0x1010e000      C:\Program Files\Logitech\SetPoint\lgscroll.dll
0x7c340000 - 0x7c396000      C:\WINDOWS\system32\MSVCR71.dll
0x7c3a0000 - 0x7c41b000      C:\WINDOWS\system32\MSVCP71.dll
0x76ee0000 - 0x76f1c000      C:\WINDOWS\system32\RASAPI32.dll
0x76e90000 - 0x76ea2000      C:\WINDOWS\system32\rasman.dll
0x5b860000 - 0x5b8b4000      C:\WINDOWS\system32\NETAPI32.dll
0x76eb0000 - 0x76edf000      C:\WINDOWS\system32\TAPI32.dll
0x76e80000 - 0x76e8e000      C:\WINDOWS\system32\rtutils.dll
0x769c0000 - 0x76a73000      C:\WINDOWS\system32\USERENV.dll
0x722b0000 - 0x722b5000      C:\WINDOWS\system32\sensapi.dll
0x76fc0000 - 0x76fc6000      C:\WINDOWS\system32\rasadhlp.dll
0x76f20000 - 0x76f47000      C:\WINDOWS\system32\DNSAPI.dll
0x76fb0000 - 0x76fb8000      C:\WINDOWS\System32\winrnr.dll
0x76f60000 - 0x76f8c000      C:\WINDOWS\system32\WLDAP32.dll
VM Arguments:
jvm_args: -Didea.launcher.port=7534 -Didea.launcher.bin.path=C:\Program Files\JetBrains\IntelliJ IDEA 6.0\bin -Dfile.encoding=windows-1252
java_command: com.intellij.rt.execution.application.AppMain system.IEConnectionJNI
Environment Variables:
CLASSPATH=.;C:\Program Files\Java\jre1.5.0_03\lib\ext\QTJava.zip
PATH=C:\oracle\product\10.2.0\db_1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\SecureCRT\;C:\exim_downloaded\bin;C:\BES\bin;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin;C:\BES\bin
USERNAME=Chris
OS=Windows_NT
PROCESSOR_IDENTIFIER=x86 Family 15 Model 3 Stepping 4, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows XP Build 2600 Service Pack 2
CPU:total 2 family 15, cmov, cx8, fxsr, mmx, sse, sse2, ht
Memory: 4k page, physical 2096340k(1206824k free), swap 4194303k(3968120k free)
vm_info: Java HotSpot(TM) Client VM (1.5.0_03-b07) for windows-x86, built on Apr 13 2005 02:07:01 by "java_re" with MS VC++ 6.0

Similar Messages

  • Why cant I delete local files when in ftp is there move command...

    why cant I delete local files when in ftp... is there a move command in FTP...

    Ignore the post by Thomasjomson1234 if it is still visible. He is a spammer attempting to phish information.

  • Why Cant I Delete in Recents Calls the ones I want to ?

    Why Cant I Delete In Recent Calls the ones I want to ?

    Because Apple designed the iOS for it to be all or nothing. You can tell Apple you'd like to see a change here:
    http://www.apple.com/feedback/iphone.html

  • TS3899 Why cant i delete all my email inbox messages together?

    Why cant i delete all my inbox email messages together?, I'm using my iPhone 5s, i can delete all my junk email messages together but not my inbox email messages, i have to individually tick each inbox message one at a time tick/delete, its extremely annoying, it doesn't make any sense, can anyone please explain why such an obviously much needed function has been left out for email inbox messages but included only for junk email messages?

    There's no one from Apple here, thus no one here can answer your question. You can make suggestions to Apple using this:
    http://www.apple.com/feedback/iphone.html

  • Why cant i delete icloud contact folders from outlook

    why cant i delete icloud contact folders from outlook

    How are you trying to delete them, and what error messages are you seeing when you do?

  • Why cant I delete some Folders / Files transfered from external HD? to!

    I am trying to figure out why I cant delete some folders / files, that I transfered from an external HD to my Macbook!
    Some of these folder / files are text, video, and pic's based. Surely, going through those video / pics / text files, those I dont need anymore I would like to delete. Some of these appear to be deleted (in trash).  But few days later I do realize, that they were not delete, or only few of the deleted files were properly deleted!
    Why is this, this way - and how can I solve this issues! I just want to delete stuff either in form of folders or files, that I dont need anymore!

    How are you trying to transfer them? What kind of external device?
    ~Lyssa

  • Why cant i delete songs off my iphone?

    so all i want to do is delete JUST ONE BAND off of my iphone to make room for other things.. the band is already deleted out of my itunes library. the files, themselves, have been thrown in my trash and deleted permanently. BUT, the band is still on my iphone. i tried syncing my iphone and it said that my iphone would need 44.1 MB of extra space.. i went into the syncing options and clicked "selected playlists, albums, artists, and genres" and unchecked every single option possible. i tried syncing that so it would delete EVERYTHING off my iphone so i could simply resync my library (minus the music i want gone). when i tried that, it shows (in the bar at the bottom) that i would have 54 GB free. but when i click sync, it says my iphone will be 1 MB over capacity.. really? since when do i have only a 2 GB harddrive on my phone?
    why is it so **** difficult to simply delete a band off my phone? ive checked google and this site for answers, but NONE of them offered a solution..

    Ignore the post by Thomasjomson1234 if it is still visible. He is a spammer attempting to phish information.

  • Hi why are my photos after downloading twice ,once in photo library and once in a file with the date why cant i delete a file its an iphone 4s please help

    why are my photos after downloadon twice one as photo library the other as a file with date how can i delete one file same pics

    Generally I would not use Facebook for sharing any photos, it compresses the photos substantially, and when you have shadows and dark colours you get visible "bands" where there should be subtle gradients, ie at sunsets and sunrises.
    It sounds like you are using two methods to upload to Facebook:
    1. Sharing from within Aperture, which basically syncs Facebook with your Aperture album, so any changes made at either end gets synced, hence the deletions from Albums, although the original file should still be in your library, just removed rom the album. It is like a playlist in iTunes.
    2. Exporting pics and uploading to Facebook from the browser.
    I am not sure how method 1 gets compressed, but I know that uploading hi-res jpegs to Facebook using method 2 results in poor quality images.
    I wouldn't even bother comparing option 1 or 2, and they will both be poor images once you view them on Facebook, as opposed to viewing uploaded images on proper image sharing / hosting sites.
    Your problem is not with Aperture, it is using Facebook for showing your work.
    If you export pics form Aperture at high res jpegs or TIFFs your images will be fine.
    If you insist to use Facebook as your way to share your work, then your workflow should be this:
    1. Right click images you want to share.
    2. Select Export version.
    3. Export as 100% size and ensure the export settings are set at 100% quality.
    4. Upload this pic into Facebook.
    This will get you the best image size and resolution on Facebook.
    See how you go.

  • Why cant I delete audio books in itunes 12

    I buy a lot of books from Audible.com and they store in itunes.  Now I cant delete them from my mac, and so I cannot delete on iphone 6 - want to free up space.  It used to be easy  ( hit delete )  Any ideas
    Gary

    I buy a lot of books from Audible.com and they store in itunes.  Now I cant delete them from my mac, and so I cannot delete on iphone 6 - want to free up space.  It used to be easy  ( hit delete )  Any ideas
    Gary

  • Why cant i delete music from icloud

    I have music in icloud which i dont want and i cant delete it? when i right click to delete from itunes it say it will be deleted from itunes but not from icloud it will be hidden. Please help, I am feed up in setting up a new pc windows and there duplicates of my songs even 4 of each how annoying?

    If you mean from iTunes Match without having them on your hard drive, then that's because they aren't on your hard drive.

  • Why cant i delete itunes

    cant delete or install itunes

    Do you get an error message when you try to install or uninstall iTunes? If so, what does it say? (Precise text, please.)

  • Why cant i delete things off of my desktop?

    I cant delete something off of my desktop because it wont let me, what do I do?

    Reboot and see whether it goes away.

  • Why cant i delete music off of my IPOD

    i just updated my Ipod today and have synced my music back onto it....I wanted to manually take off some music and add other and it wont let me delete music off of my device......WHY?

    Reboot and see whether it goes away.

  • Why cant I delete photos from event in Iphoto 08?

    Set to edit in external editor. After trying to open movie, return to event and cannot delete photos. Open and close program a couple of times, reset to edit in new window, re-open program and I can delete, but only by dragging to the trash located in Iphoto window (cannot drag to desktop trash, use delete key, use command-option-delete etc). Works on a couple of photos, then will not let me delete in any manner again.
    Any idea what's going on?
    Thanks
    Dave

    Using Photoshop (or Photoshop Elements) as Your Editor of Choice in iPhoto.
    1 - select Photoshop as your editor of choice in iPhoto's General Preference Section's under the "Edit photo:" menu.
    2 - double click on the thumbnail in iPhoto to open it in Photoshop. When you're finished editing click on the Save button. If you immediately get the JPEG Options window make your selection (Baseline standard seems to be the most compatible jpeg format) and click on the OK button. Your done.
    3 - however, if you get the navigation window that indicates that PS wants to save it as a PS formatted file. You'll need to either select JPEG from the menu and save (top image) or click on the desktop in the Navigation window (bottom image) and save it to the desktop for importing as a new photo.
    This method will let iPhoto know that the photo has been editied and will update the thumbnail file to reflect the edit..
    NOTE: With Photoshop Elements 6 the Saving File preferences should be configured: "On First Save: Save Over Current File". Also I suggest the Maximize PSD File Compatabilty be set to Always.
    If you want to use both iPhoto's editing mode and PS without having to go back and forth to the Preference pane, once you've selected PS as your editor of choice, reset the Preferences back to "Open in main window". That will let you either edit in iPhoto (double click on the thumbnail) or in PS (Control-click on the thumbnail and seledt "Edit in external editor" in the Contextual menu). This way you get the best of both worlds
    2 - double click on the thumbnail in iPhoto to open it in Photoshop. When you're finished editing click on the Save button. If you immediately get the JPEG Options window make your selection (Baseline standard seems to be the most compatible jpeg format) and click on the OK button. Your done.
    3 - however, if you get the navigation window that indicates that PS wants to save it as a PS formatted file. You'll need to either select JPEG from the menu and save (top image) or click on the desktop in the Navigation window (bottom image) and save it to the desktop for importing as a new photo.
    This method will let iPhoto know that the photo has been editied and will update the thumbnail file to reflect the edit..
    OT

  • Why cant i delete messages in my apple mailbox

    I delete the messages and they don't go to the trash.
    The messages just stay in the inbox and won't delete.

    With the message open or highlighted, are you using the delete button in the toolbar?
    Or, you can just highlight the message and drag it manually over to the trashcan in the sidebar.

Maybe you are looking for

  • DVD audio, no video

    My dvd player plays the audio nbut no video...so it is stuck on the menu screen---although the movie window is just black.

  • Error While Creating PAS Procedure

    Dear Friends I am getting following error while creating PAS procedure. I login using Admin Access to Database Admin.EWK Denied by the Operating System What might be the reason for this error? Rgds SriG

  • Screen hangs while booting from Install disk

    I'm trying to install 10.3.1 using my original disks onto an iBook G4 I bought from eBay that has 10.3.9 on it. The iBook works fine, but I don't have the administrator password and the seller has long along stopped answering my emails. I'm installin

  • Date should be displayed on query execution

    hello all when v execute a query date should display when query is executed.like if i execute query on 01/06/2006 this date should be displayed and when execute query on 01/02/2006 this date should be displayed?,like that so on? kindly anyone let me

  • HT5071 EPUB converter other than Calibre?

    Hello, I want to get my work published on iBook but I'm having difficulties in delivering my package on iTunes Producer since it's not accepting the epub file I used from Calibre. The original file is PDF and I've converted it to EPUB on Calibre. I'v