Do I need to use free() to deallocate memory allocated by GetStringUTF?

Question 1:
If I do...
char * str = (char *) jEnv->GetStringUTFChars((jstring) jStr, 0);Then, can I use free() over str? i.e.
jEnv->ReleaseStringUTFChars((jstring) jStr, str);
free(str); //Is this line valid or outright wrong?
Question 2:
Another question is if ReleaseStringUTFChars actually frees str then will it set str to NULL? I guest not as we are not sending this pointer by reference.
Question 3:
My last question is if str is NULL then calling ReleaseStringUTFChars over it can cause any problem?
Edited by: AppleGrew on 06-Oct-2009 14:48
Edited by: AppleGrew on 06-Oct-2009 15:02

jEnv->ReleaseStringUTFChars((jstring) jStr, str);free(str); //Is this line valid or outright wrong?Outright wrong.
Another question is if ReleaseStringUTFChars actually frees str then will it set str to NULL?No, that's impossible by the semantics of C and C++.
I guess not as we are not sending this pointer by reference.Exactly, so what you described is impossible. No need to ask really.
My last question is if str is NULL then calling ReleaseStringUTFChars over it can cause any problem?How could it be null? If it comes from GetStringUTFChars that's impossible, and if it doesn't you don't have any business calling ReleaseStringUTFChars() on it, whatever its value.

Similar Messages

  • My macbook pro's memory is full and I purchased an external hard drive. I am using timemachine, but need to earse/free up some memory on my laptop. How do I do this?

    My macbook pro's memory is full and I purchased an external hard drive. I am using timemachine, but need to earse/free up some memory on my laptop. How do I do this?

    Christinag1317 wrote:
    My macbook pro's memory is full and I purchased an external hard drive. I am using timemachine, but need to earse/free up some memory on my laptop. How do I do this?
    Ok when you refer to "memory" that is the Random Access Memory which is temporary memory the processor (worker) uses to store stuff while it's using it. Power goes off whats in the memory is gone.
    Your storage drive is where data is pernamnetly stored if the power is on/off.
    So what you really mean to say is your storage drive is filled up and you need to make some room.
    You have a TimeMachine drive, what this does is makes a image of your internal storage drive as a backup method, it also allows some "back in time" restoration of your previous deleted files depending how much space is on that drive. The more space, the less data you have, the more days you can go back in time to retrieve something.
    Unfortunatly the TimeMachine drive is not a extra space storage drive, it automatically rotates what appears on your internal storage drive. So if you delete something from the internal drive, it eventually gets deleted from the TimeMachine drive.
    So you need to make some more room on your internal drive, this is rather easy, all you need is ANOTHER external drive and connect it to the Mac. Give it a name like ExtraStorage#1 and thenyou will have to decide which of your User files you really don't need on the internal drive.
    For instance the best choice would be to move some movies out of your Movies folder to another MoviesExtra folder on the ExtraStorage#1 drive.
    Movies take a LOT of drive space and you can always copy them on or off, or watch them from the ExtraStorage#1 drive as well. But if your going to do this a lot, you should consider getting a Firewire 800/400, USB 3,2,1 combination drive as Firewire 800 is fastest and decently priced (Thunderbolt is very high priced and overkill at this time)
    The other things like Documents are quite small, Pictures can take a lot of space if you have a lot, but if you need them on the internal drive then that's better. Music one tends to use a lot or manage playlists and such, but perhaps some music you may which to move off or "prune", I suggest always burning data DVD's of music especially for extra backups.
    Once you have freed some room on the internal drive, this liitle neat program will show you what is taking the largest amount of space on your internal drive.
    http://grandperspectiv.sourceforge.net/
    After a scan, right click on the big squares to "revel in Finder" to show you what's taking the largest amount of space, be warned it also opens up hidden system files and folders, which you won't be able to move. So concentrate on what's inthe Users folder.
    Likely if you have a lot of Movies this is the biggest culprit on most standard internal hard drives. Also if you have something in iTunes that's auto-downloading something like PodCasts and not deleting the older ones and you forget. So go there and fix things and that can free up drive space.
    If you bought a small SSD with your new Mac, then the price of that SSD has come back to haunt you with low storage space, you will have to think carefully what you can live without on the internal drive.
    Once you have slimmed things down, TimeMachine will update to reflect your slimmer internal drive. What this means is there is only one copy of your data on the ExtraStorage#1 drive.
    You need to maintain two copies of your data at all times on seperate hardware, so now you need ANOTHER storage drive (ExtraStorage#2) to copy everythinng of ExtraStorage#1, or else if you drop or have a mechanical problem with ES#1 all that data will be gone!
    If you wish to learn more then I suggest reading these two links
    https://discussions.apple.com/message/16276201#16276201
    http://pondini.org/OSX/Home.html

  • Which way is used to allocate/deallocate memory for locals?

    Good afternoon.
    I would like to know how memory is allocated/deallocated for local variables in an activation record/frame. For example, in the following java code:
    1 public void test()
    2 {
    3     {          
    4          {
    5               String y = "abc";
    6          }
    7     }
    8     {
    9          String y = "pqr";
    10     }
    11 } At line 5, memory is allocated for variable y. Is this memory deallocated at line 6 (right after its declaration block), or after the line 11 at which point the whole activation record for the method is popped out of the stack?
    In addition, is this local memory allocation/deallocation strategy required by the Java specification, or could be different with different Java compilers? Thank you very much and have a great weekend,
    Sunny

    Hi,
    Thank you for your comments!
    Perhaps I did not state my problems clearly. Here is my real purpose: I am trying to monitor a program's runtime behavior by dynamically maintaining an object graph where nodes represent runtime objects and directed edges represent "refer to" relation between objects. To better understand my questions, let me first briefly introduce my algorithm to update the object graph:
    1. add an edge (between objects): when a local refers to an object, add an edge from the enclosing object to the referred object
    2. delete an edge: when a local refers to another new object, delete the edge from the enclosing object to the previously referred object; or the memory allocated for this local is deallocated.
    For example, if I have the following Java method,
    1 m()
    2 {
    3        {
    4                 Object x = objA;
    4'                x = objB;
    5                 // some statements
    6        }
    7        {
    8                 // some statements
    8'                Object x = objC;
    9        }
    10 }Below, the enclosing obj means the object containing the method m().
    At line 4, a local name x is declared and assigned objA, at which point an edge from the enclosing obj to objA should be added. At line 4' the same local is assigned a new value, at which point we should delete the edge from the enclosing obj to objA and add a new edge to objB.
    At line 6 this local is out of its scope, whether or not we should delete the edge from the enclosing obj to objB depends on whether the memory allocated for x is deallocated.
    Lastly, at line 8' a new local with the same name x is declared so we should add a new edge...
    Another example is like this:
    1 m1()
    2 {
    3      Object x = objA;
    4     // some statements
    5     m2();
    6 }
    7 m2()
    8 {
    9     Object x = objB;
    10     // some statements
    11 }After line 9, I should be able to know the enclosing obj has two outgoing edges labeled with x, one is to objA and the other is to objB.
    Is there any solution to getting this runtime information for Java local variables? I would really appreciate any help!
    -- Sunny

  • Garageband 11: lagging or unresponsive interface; frequently crashes; and is using way too much memory

    Since updating to the newest version of Garageband I've noticed a distinct slow down in interface and functionality; makes editing incredibly difficult having to wait 2-3 seconds after selecting a note or section; sometimes the whole app becomes unresponsive or just crashes altogether. It also completely maxes out memory usage (8GB!) My machine specs are below but I can't imagine why I couldn't run it. It boots up in about 5 seconds and before Mavericks I could run Logic, Garageband, MS Word, Adobe Edge Animate, and Adobe Muse without it breaking a sweat. Now it's running the fans at full blast using way more memory than is necessary.
    My Machine
    The OS and Applications run off of a 120GB SSD and instead of an Optical drive I use a data doubler and a second internal (500GB HDD) for backups and extra storage - neither are anywhere near capacity.
    Also, I'm not running any other apps, and even tried disabling network connections; no change at all. I do know that Mavericks uses memory differently (don't fully understand the benifit or how it works) but when I open Activity Monitor while running GarageBand it show's my "Memory Used:" at 7.99GB/8GB; but the pressure is still in the green. Could someone please explain to me how the memory usage differs now and why my machine needs to use all of the memory at once to run GarageBand when it is the only app open?
    Why is it that 10.9 is substantially more taxing than 10.8 while claiming to be the opposite? What am I missing here?
    Please Help! :-)

    Since updating to the newest version of Garageband I've noticed a distinct slow down in interface and functionality;
    Your question is a bit ambigious - the "Newest version" would be GarageBAnd 10.0.1, but the title of your question says GarageBand '11. Are you saying, you upgraded to GarageBand 10.0, but now GarageBand '11 (version 6.0.5) is having troubles?
    makes editing incredibly difficult having to wait 2-3 seconds after selecting a note or section; sometimes the whole app becomes unresponsive or just crashes altogether.
    Perhaps a crash log could help. Or error messages from the Console window. Does the Console.app show any diagnostic messages, when this hanging occurs?
    and before Mavericks I could run Logic, Garageband, MS Word, Adobe Edge Animate, and Adobe Muse without it breaking a sweat.
    Have all these applications been updated to the latest, Mavericks compatible versions? And all other non-Apple applications?

  • We have always used one iTunes account and I want to crate a new account for my daughter.  What is the best way to go about this and will she need to download free apps again?

    We have always used one iTunes account and I want to crate a new account for my daughter.  What is the best way to go about this and will she need to download free apps again?

    Not going to happen the way you want it to.
    When you add a gift card balance to the Apple ID, it's available for the Apple ID.
    Probably best to create unique Apple ID's for each... this will also make things easier in the future as purchases are eternally tied to the Apple ID they were purchased with.

  • I already updated! The version iOS 6.0.1 without include me the McTube or MxTube. The McTube free I was using, capacity for 10 videos download only. I need McTube Pro free! What's your Idea?

    I already updated! The version iOS 6.0.1 without include me the McTube or MxTube. The McTube free I was using, capacity for 10 videos download only. I need McTube Pro free! What's your Idea?

    I already updated! The version iOS 6.0.1 without include me the McTube or MxTube. The McTube free I was using, capacity for 10 videos download only. I need McTube Pro free! What's your Idea?

  • IPhone 5s with hearing aids via Bluetooth. Need to use the phone for voice, what's the best distance that the mic will pick up your voice

    I wear hearing aids that are made for Apple, the audio will go into the hearing aids via Bluetooth. I'll need to use my phone for voice only.. I drive for work and have a wok oh one too and both are synced to a bluetooh headset (LG). I'm trying to figure out how to talk on both phones ( use speakerphone on work phone?) without using a bluretooh headset.  I don't know the range of the microphone on the IPHON, thinking about hanging it around my neck or put the phone into a stand/holder on the dash and use the speakerphone feature.  Looking for ideas to make this simple

    You can't do anything with that problem.
    Take your iPhone to the closest Apple Store and they will give you new one for 200€/$ or if you bought your iPhone in less than 12 months you will get it for free.

  • HT5622 I want to use free apps on my Ipad and do NOT wish to submit a credit card to Itunes.  My Apple Id works, but won't let me migrate past the credit card phase in itunes.  I don't wish to sumbit or use a credit card because I will not make purchases.

    I want to use free apps on Ipad 2, but it continually asks me to submit a credit card in Itunes.  I do not wish to purchase anything apps or music.  I am only interested in free apps.  If I were to make purchases, I would use a prepaid card like an itunes card or an app card, but NEVER a credit card.  I can't seem to bypass this option of using a credit card and need to.  I have another Ipad 4 and have never needed to use my credit card to migrate past itunes to use any apps.  How do I get past this credit card request and still use my ipad 2.  According to my Ipad 2, if I don't plug in a credit card, I can't even use free apps which is stupid.

    You can create an iTune and App Store account without credit card details
    1. Sign out of current Apple ID if you are sign-in to one (important)
    2. Go to App Store and select a free app
    3. Tap INSTALL APP
    4. Create New Apple ID
    5. Confirm Your Country
    6. Agree with Terms and Conditions
    7. Fill in your Apple ID and Password (you must create a new Apple ID; don't use your old Apple ID)
    8. Create and answer your secret question
    9. Select NONE for Payment Method
    10. Fill in Billing Address
    11. Submit application for new Apple ID
    12. Wait for verification email
    13. When email arrive, verify your account
    14. Start downloading your free apps

  • Can i use a class for this or do i need to use a type def

    what i am trying to do is have a parent cluster witch has a file name and some free space to put is children's data in with decorations at the bottom.
    i then need to have a child with a graph in the middle blank space of the parent.
    i also need to have another child with a table in the middle blank space.
    can i do this with classes or do i need to use typdefs.
    tks in advance

    Hello vivi,
    I'm not entirely sure what you mean.  The classes that you create in LabVIEW 8.2 are meant to be containers for data and methods, not displayable items.  Even though a class's private data members are defined in a cluster, you can't think of a class and a cluster as the same thing.  A cluster is an object that you can use to bundle different kinds of information together.  You can also design a cluster to be displayed on a front panel.
    If you want to use LabVIEW's object oriented features, I would suggest creating a class which stores your objects data (non displayable).  You could then create a method on your class to convert some of its internal data into a cluster which can be displayed to the user.
    Regards,
    Justin D
    Applications Engineer
    National Instruments

  • I'm trying to manually sync my music to my iPhone but it needs so much free space

    I used to be synced to a different iTunes on a different computer. Now that I have my own laptop with my on music library I'm trying to sync it to my phone. I have to do it manually because I don't have enough space on my phone to sync my entire music library. But every time I try to sync it, it will tell me that it's unable to sync because it needs "at least 3.something more GB of space in order to sync" and every time I unselect an artist it will say it needs more space until I have barely any of my music selected. Why does it need so much free space? Like it requires approx 5GB of free space in order to sync my music and I don't understand why. I've never had this issue before. I even imported all of my pictures to my laptop so I could delete them to make room for my music. Please help me.

    Hi there Sarbunn,
    You may find the information in the article below helpful if there is not enough free space on your device to sync.
    If you get a "Not enough free space" alert on your iPhone, iPad, or iPod touch 
    -Griff W.  

  • What  type of plug in do I need to use between weblogic and tomcat please

    Hi,
    Can anybody please tell me what type of plugin do I need to install to communicate between Tomcat4.0 and weblogic6.1 sp2.actually I wanted to use a connection pool from my servlet on my local tomact where connection pool is created on remote weblogic server.........?
    I have no idea what to do. I tried including the weblogic.jar in my local classpath where my tomcat is sitting. This didnot work . I got the following error......
    I want to know is it possible.............?
    javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory]
    Your response is very inportant......
    Thnaks

    Thanks a lot for your rely....
    then how could I use the remote connection pool in my
    local Tomcat server.....?If thats is not possible then
    what if organisation have two webservers...? you mean
    thay have to create connection pool in two servers
    rather on one server and use it every where.....?
    Still depends on what you are trying to achieve.
    Most clustered systesm use a connections on each server. They sync the data retrieved between servers, not the connections themselves.
    If you simply one a single connection point then you need to use a driver that proxies requests to and from the real connection point.
    RmiJdbc is free at http://www.objectweb.org/.
    There are commercial drivers available, search at http://industry.java.sun.com/products/jdbc/drivers, which provide an enterprise layer for database access. They are probably more robust and feature rich than the above one.

  • I have a MacBook Pro running Lion. I need to use Lion to run my Dragon. I would like to partition my drive to use Maverick for everything but the dictation software. I'm a new pie to apple

    I have a MacBook Pro running Lion. I need to use Lion to run my Dragon. I would like to partition my drive to use Mavericks for everything but the dictation software. I'm a newbie to apple

    To resize the drive do the following:
    1. Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
    After the main menu appears select Disk Utility and click on the Continue button. Select the hard drive's main entry then click on the Partition tab in the DU main window.
    2. You should see the graphical sizing window showing the existing partitions. A portion may appear as a blue rectangle representing the used space on a partition.
    3. In the lower right corner of the sizing rectangle for each partition is a resizing gadget. Select it with the mouse and move the bottom of the rectangle upwards until you have reduced the existing partition enough to create the desired new volume's size. The space below the resized partition will appear gray. Click on the Apply button and wait until the process has completed.  (Note: You can only make a partition smaller in order to create new free space.)
    4. Click on the [+] button below the sizing window to add a new partition in the gray space you freed up. Give the new volume a name, if you wish, then click on the Apply button. Wait until the process has completed.
    You should now have a new volume on the drive.
    It would be wise to have a backup of your current system as resizing is not necessarily free of risk for data loss.  Your drive must have sufficient contiguous free space for this process to work.

  • My account is inactive, My PS says it´s inactive, Adobe support says it´s active, I´m using Free trial or else, but I have paid

    Your Customer identification number registered with us is
    [personal information removed... Mod - https://forums.adobe.com/docs/DOC-3731]
    [This is an open forum, not Adobe support, please do not post personal information]
    "We apologize for not being answerable to your request in a timely manner. We understand that you are unable to use the subscription as it's showing suspended. However, I checked and see that the subscription is active and you can go ahead and use the subscription." (Adobe Support)
    I am currently using free trial or else my  PS would be blocked.
    I still need help, I don´t understand what´s happening. Please, somebody help.
    Thanks

    Online Chat Now button near the bottom for Activation and Deactivation problems may help
    http://helpx.adobe.com/x-productkb/policy-pricing/activation-deactivation-products.html

  • How to deallocate memory used by the labview program?

    Hi,
    I have bulit a large application in labview 2012 that uses a couple of subvis, local and global variables, some uninitialized shift registers (functional global variables) and some c++ and .net dlls as well. When I open my application the memory usage shown at Windows task manager is around 1.4GB. After running the application and enabling all processes used in the application, the memory usage goes up to 1.55GB but when i stop the application, memory is never released/deallocated until i close the application plus exit labview. Can you suggest how to deallocate this memory? and how can i use the request deallocation function for this application? labview help says i have to place it inside a subVI for which i want to deallocate memory. But i have a lot of subVIs used in my application. I tried placing it in the top level VI and called it after stopping all processes but it didn't work... I am also closing references to all of the .net dlls at the end. Any workarounds??
    Thanks

    sandee wrote:
    When I open my application the memory usage shown at Windows task manager is around 1.4GB. After running the application and enabling all processes used in the application, the memory usage goes up to 1.55GB but when i stop the application, memory is never released/deallocated until i close the application plus exit labview.
    You already got some good advice. One thing that was not clear was how you are measuring memory. Since the task manager is capable of showing the memory used by LabVIEW alone (you simply need to look elsewhere), and you said that the memory gets released when you exit LabVIEW, you gave the impression that the 1.4GB was the LabVIEW portion.
    OK, so a couple of hundred MB used by LabVIEW is really nothing to worry about. Are you running into memory or other performance problems? What are the symptoms?
    sandee wrote:
    I have bulit a large application in labview 2012 that uses a couple of subvis, local and global variables, some uninitialized shift registers (functional global variables) and some c++ and .net dlls as well.
    We really need to see some code. It is very well posssible that you have a lots of unecessary data copies in memory due to sloppy programming. How big are the data structures? Do you use local variables for big data structures? What does the program actually do?
    LabVIEW Champion . Do more with less code and in less time .

  • Do I still need to use the old mobile me backup system for backing up a mac desktop and if I delete it will it affect the memory of my system which has now Maverics

    Do I still need to use the old mobile me backup system for backing up all my data and having it able to get at in case of a crash, or can the icloud reset everything? Because I can not find any structured refrence, as to how it would be done. I am updated to Maverics. Also does the icloud continue if I uninstall the backup to free up space?

    MobileMe was discontinued in 2012 and all the data stored on it was deleted, and iCloud can't make backups of Macs.
    What I recommend you to make backups is to get an external drive and use Time Machine or an application like Carbon Copy Cloner. With this, you can access to your data everywhere and safely, and then, if you want, use a cloud storage service like CrashPlan. You can keep on using iCloud without backups

Maybe you are looking for