VEEINK SXY Paperbag Waist Double Pocket Carrot Pants

VEEINK SXY Paperbag Waist Double Pocket Carrot Pants

Looking for something unique in pants? Check out VEEINK’s SXY Paperbag Waist Double Pocket Carrot Pants. With a paperbag waist and double pockets, these pants are sure to turn heads. Made from a carrot print fabric, these pants are perfect for making a statement.Q:

Does the Java Memory Model guarantee proper dereferencing of objects even if the object is not reachable?

I’m working on a project which handles a lot of memory allocation, freeing, and copying, and has an important performance requirement that some critical region of code must not make any allocations, even in the case of failed allocation attempts.
We implemented this by having the entire code path of the program write their own object wrappers around their data values. When an allocation attempt fails, the wrapper object is marked as “invalid”, and is simply not deallocated when another allocation is made, so that allocations can’t continue to be made within the critical region until the failure is resolved.
The critical region also can’t allocate more memory, and must not allocate on the stack or heap. (We handle that case by having threads of the program each take up their own private heap space)
With this approach, objects must be explicitly released by using the wrapper object to fetch pointers to their data value. When I do this, I must make sure that the thread is guaranteed to dereference the value until the value is deallocated, or it will leak memory.
So my question is this: Do Java’s memory model guarantees that this will work, or is it possible for the runtime to decide to dereference some object even though it’s not reachable? I’ve been reading the documentation on volatile, but it appears to only provide a mechanism for the runtime to prevent this kind of thing, and in my case don’t want to rely on that.
To clarify, the code I need to make sure doesn’t leak memory has only 2 uses of a pointer:

Getting the raw data pointer from the object – if the object is invalidated, this pointer cannot be accessed any more.
Calling a member function that returns a reference (or the raw data) – the function cannot return an invalid object pointer due to above.


I have tested your situation (but without the critical regions described), and it seems that dereferencing a pointer from an invalidated object will never “leak” memory.
The program I created looked like this:
public class Validate {
int myInt;
private int myInt2;

void set(int myInt) {

Leave a Reply